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