]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/initializers/constants.js
Server: fix videos pagination
[github/Chocobozzz/PeerTube.git] / server / initializers / constants.js
CommitLineData
9f10b292
C
1'use strict'
2
3// API version of our pod
f0f5567b 4const API_VERSION = 'v1'
9f10b292
C
5
6// Score a pod has when we create it as a friend
a3ee6fa2
C
7const FRIEND_SCORE = {
8 BASE: 100,
9 MAX: 1000
10}
9f10b292 11
8483b221
C
12// Time to wait between requests to the friends (10 min)
13let INTERVAL = 600000
9f10b292 14
3fe81fa7
C
15// Number of results by default for the pagination
16const PAGINATION_COUNT_DEFAULT = 15
17
9f10b292 18// Number of points we add/remove from a friend after a successful/bad request
f0f5567b 19const PODS_SCORE = {
9f10b292
C
20 MALUS: -10,
21 BONUS: 10
22}
23
528a9efa
C
24// Number of requests in parallel we can make
25const REQUESTS_IN_PARALLEL = 10
9f10b292 26
528a9efa
C
27// Number of requests to retry for replay requests module
28const RETRY_REQUESTS = 5
8c255eb5 29
46246b5f
C
30// Sortable columns per schema
31const SEARCHABLE_COLUMNS = {
8d199cb8 32 VIDEOS: [ 'name', 'magnetUri', 'podUrl', 'author', 'tags' ]
46246b5f
C
33}
34
a877d5ac
C
35// Sortable columns per schema
36const SORTABLE_COLUMNS = {
37 VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdDate', '-createdDate' ]
38}
39
cbe2f7c3
C
40// Videos thumbnail size
41const THUMBNAILS_SIZE = '200x110'
42
43// Path for access to thumbnails with express router
44const THUMBNAILS_STATIC_PATH = '/static/thumbnails'
45
be587647 46const VIDEOS_CONSTRAINTS_FIELDS = {
e822fdae
C
47 NAME: { min: 3, max: 50 }, // Length
48 DESCRIPTION: { min: 3, max: 250 }, // Length
be587647
C
49 MAGNET_URI: { min: 10 }, // Length
50 DURATION: { min: 1, max: 7200 }, // Number
51 AUTHOR: { min: 3, max: 20 }, // Length
52 TAGS: { min: 1, max: 3 }, // Number of total tags
53 TAG: { min: 2, max: 10 }, // Length
aaf61f38
C
54 THUMBNAIL: { min: 2, max: 30 },
55 THUMBNAIL64: { min: 0, max: 20000 } // Bytes
be587647
C
56}
57
9f10b292
C
58// Special constants for a test instance
59if (isTestInstance() === true) {
a3ee6fa2 60 FRIEND_SCORE.BASE = 20
9f10b292 61 INTERVAL = 10000
be587647 62 VIDEOS_CONSTRAINTS_FIELDS.DURATION.max = 14
9f10b292
C
63}
64
65// ---------------------------------------------------------------------------
66
67module.exports = {
68 API_VERSION: API_VERSION,
a3ee6fa2 69 FRIEND_SCORE: FRIEND_SCORE,
9f10b292 70 INTERVAL: INTERVAL,
3fe81fa7 71 PAGINATION_COUNT_DEFAULT: PAGINATION_COUNT_DEFAULT,
9f10b292 72 PODS_SCORE: PODS_SCORE,
528a9efa
C
73 REQUESTS_IN_PARALLEL: REQUESTS_IN_PARALLEL,
74 RETRY_REQUESTS: RETRY_REQUESTS,
46246b5f 75 SEARCHABLE_COLUMNS: SEARCHABLE_COLUMNS,
a877d5ac 76 SORTABLE_COLUMNS: SORTABLE_COLUMNS,
cbe2f7c3 77 THUMBNAILS_SIZE: THUMBNAILS_SIZE,
be587647
C
78 THUMBNAILS_STATIC_PATH: THUMBNAILS_STATIC_PATH,
79 VIDEOS_CONSTRAINTS_FIELDS: VIDEOS_CONSTRAINTS_FIELDS
9f10b292
C
80}
81
82// ---------------------------------------------------------------------------
83
84function isTestInstance () {
85 return (process.env.NODE_ENV === 'test')
86}