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