]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/initializers/constants.js
d87a376d321691ee4703fcfa678c47f94b6bba6e
[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 let FRIEND_BASE_SCORE = 100
8
9 // Time to wait between requests to the friends
10 let INTERVAL = 60000
11
12 // 2 hours maximum for the duration of a video (in seconds)
13 let MAXIMUM_VIDEO_DURATION = 7200
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 retries we make for the make retry requests (to friends...)
25 let REQUEST_RETRIES = 10
26
27 // Videos thumbnail size
28 const THUMBNAILS_SIZE = '200x110'
29
30 // Path for access to thumbnails with express router
31 const THUMBNAILS_STATIC_PATH = '/static/thumbnails'
32
33 // Special constants for a test instance
34 if (isTestInstance() === true) {
35 FRIEND_BASE_SCORE = 20
36 INTERVAL = 10000
37 MAXIMUM_VIDEO_DURATION = 14
38 REQUEST_RETRIES = 2
39 }
40
41 // ---------------------------------------------------------------------------
42
43 module.exports = {
44 API_VERSION: API_VERSION,
45 FRIEND_BASE_SCORE: FRIEND_BASE_SCORE,
46 INTERVAL: INTERVAL,
47 MAXIMUM_VIDEO_DURATION: MAXIMUM_VIDEO_DURATION,
48 PAGINATION_COUNT_DEFAULT: PAGINATION_COUNT_DEFAULT,
49 PODS_SCORE: PODS_SCORE,
50 REQUEST_RETRIES: REQUEST_RETRIES,
51 THUMBNAILS_SIZE: THUMBNAILS_SIZE,
52 THUMBNAILS_STATIC_PATH: THUMBNAILS_STATIC_PATH
53 }
54
55 // ---------------------------------------------------------------------------
56
57 function isTestInstance () {
58 return (process.env.NODE_ENV === 'test')
59 }