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