]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/initializers/constants.js
Server: do not enable images tests by default because it needs a special
[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 const OAUTH_LIFETIME = {
16 ACCESS_TOKEN: 3600 * 4, // 4 hours
17 REFRESH_TOKEN: 1209600 // 2 weeks
18 }
19
20 // Number of results by default for the pagination
21 const PAGINATION_COUNT_DEFAULT = 15
22
23 // Number of points we add/remove from a friend after a successful/bad request
24 const PODS_SCORE = {
25 MALUS: -10,
26 BONUS: 10
27 }
28
29 // Number of requests in parallel we can make
30 const REQUESTS_IN_PARALLEL = 10
31
32 // How many requests we put in request (request scheduler)
33 const REQUESTS_LIMIT = 10
34
35 // Number of requests to retry for replay requests module
36 const RETRY_REQUESTS = 5
37
38 // Sortable columns per schema
39 const SEARCHABLE_COLUMNS = {
40 VIDEOS: [ 'name', 'magnetUri', 'podUrl', 'author', 'tags' ]
41 }
42
43 // Sortable columns per schema
44 const SORTABLE_COLUMNS = {
45 VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdDate', '-createdDate' ]
46 }
47
48 // Videos thumbnail size
49 const THUMBNAILS_SIZE = '200x110'
50
51 // Path for access to thumbnails with express router
52 const THUMBNAILS_STATIC_PATH = '/static/thumbnails'
53
54 const VIDEOS_CONSTRAINTS_FIELDS = {
55 NAME: { min: 3, max: 50 }, // Length
56 DESCRIPTION: { min: 3, max: 250 }, // Length
57 MAGNET_URI: { min: 10 }, // Length
58 DURATION: { min: 1, max: 7200 }, // Number
59 AUTHOR: { min: 3, max: 20 }, // Length
60 TAGS: { min: 1, max: 3 }, // Number of total tags
61 TAG: { min: 2, max: 10 }, // Length
62 THUMBNAIL: { min: 2, max: 30 },
63 THUMBNAIL64: { min: 0, max: 20000 } // Bytes
64 }
65
66 // Special constants for a test instance
67 if (isTestInstance() === true) {
68 FRIEND_SCORE.BASE = 20
69 INTERVAL = 10000
70 VIDEOS_CONSTRAINTS_FIELDS.DURATION.max = 14
71 }
72
73 // ---------------------------------------------------------------------------
74
75 module.exports = {
76 API_VERSION: API_VERSION,
77 FRIEND_SCORE: FRIEND_SCORE,
78 INTERVAL: INTERVAL,
79 OAUTH_LIFETIME: OAUTH_LIFETIME,
80 PAGINATION_COUNT_DEFAULT: PAGINATION_COUNT_DEFAULT,
81 PODS_SCORE: PODS_SCORE,
82 REQUESTS_IN_PARALLEL: REQUESTS_IN_PARALLEL,
83 REQUESTS_LIMIT: REQUESTS_LIMIT,
84 RETRY_REQUESTS: RETRY_REQUESTS,
85 SEARCHABLE_COLUMNS: SEARCHABLE_COLUMNS,
86 SORTABLE_COLUMNS: SORTABLE_COLUMNS,
87 THUMBNAILS_SIZE: THUMBNAILS_SIZE,
88 THUMBNAILS_STATIC_PATH: THUMBNAILS_STATIC_PATH,
89 VIDEOS_CONSTRAINTS_FIELDS: VIDEOS_CONSTRAINTS_FIELDS
90 }
91
92 // ---------------------------------------------------------------------------
93
94 function isTestInstance () {
95 return (process.env.NODE_ENV === 'test')
96 }