]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/initializers/constants.js
3 const config
= require('config')
4 const path
= require('path')
6 // ---------------------------------------------------------------------------
9 const API_VERSION
= 'v1'
11 // Number of results by default for the pagination
12 const PAGINATION_COUNT_DEFAULT
= 15
14 // Sortable columns per schema
15 const SEARCHABLE_COLUMNS
= {
16 VIDEOS: [ 'name', 'magnetUri', 'host', 'author', 'tags' ]
19 // Sortable columns per schema
20 const SORTABLE_COLUMNS
= {
21 USERS: [ 'username', '-username', 'createdAt', '-createdAt' ],
22 VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdAt', '-createdAt' ]
25 const OAUTH_LIFETIME
= {
26 ACCESS_TOKEN: 3600 * 4, // 4 hours
27 REFRESH_TOKEN: 1209600 // 2 weeks
30 // ---------------------------------------------------------------------------
34 PORT: config
.get('listen.port')
37 DBNAME: 'peertube' + config
.get('database.suffix'),
38 HOSTNAME: config
.get('database.hostname'),
39 PORT: config
.get('database.port'),
40 USERNAME: config
.get('database.username'),
41 PASSWORD: config
.get('database.password')
44 CERT_DIR: path
.join(__dirname
, '..', '..', config
.get('storage.certs')),
45 LOG_DIR: path
.join(__dirname
, '..', '..', config
.get('storage.logs')),
46 VIDEOS_DIR: path
.join(__dirname
, '..', '..', config
.get('storage.videos')),
47 THUMBNAILS_DIR: path
.join(__dirname
, '..', '..', config
.get('storage.thumbnails')),
48 PREVIEWS_DIR: path
.join(__dirname
, '..', '..', config
.get('storage.previews')),
49 TORRENTS_DIR: path
.join(__dirname
, '..', '..', config
.get('storage.torrents'))
52 SCHEME: config
.get('webserver.https') === true ? 'https' : 'http',
53 WS: config
.get('webserver.https') === true ? 'wss' : 'ws',
54 HOSTNAME: config
.get('webserver.hostname'),
55 PORT: config
.get('webserver.port')
58 CONFIG
.WEBSERVER
.URL
= CONFIG
.WEBSERVER
.SCHEME
+ '://' + CONFIG
.WEBSERVER
.HOSTNAME
+ ':' + CONFIG
.WEBSERVER
.PORT
59 CONFIG
.WEBSERVER
.HOST
= CONFIG
.WEBSERVER
.HOSTNAME
+ ':' + CONFIG
.WEBSERVER
.PORT
61 // ---------------------------------------------------------------------------
63 const CONSTRAINTS_FIELDS
= {
65 USERNAME: { min: 3, max: 20 }, // Length
66 PASSWORD: { min: 6, max: 255 } // Length
69 NAME: { min: 3, max: 50 }, // Length
70 DESCRIPTION: { min: 3, max: 250 }, // Length
71 EXTNAME: [ '.mp4', '.ogv', '.webm' ],
72 INFO_HASH: { min: 10, max: 50 }, // Length
73 DURATION: { min: 1, max: 7200 }, // Number
74 TAGS: { min: 1, max: 3 }, // Number of total tags
75 TAG: { min: 2, max: 10 }, // Length
76 THUMBNAIL: { min: 2, max: 30 },
77 THUMBNAIL64: { min: 0, max: 20000 } // Bytes
81 // ---------------------------------------------------------------------------
83 // Score a pod has when we create it as a friend
84 const FRIEND_SCORE
= {
89 // ---------------------------------------------------------------------------
91 const LAST_MIGRATION_VERSION
= 0
93 // ---------------------------------------------------------------------------
95 // Number of points we add/remove from a friend after a successful/bad request
101 // Time to wait between requests to the friends (10 min)
102 let REQUESTS_INTERVAL
= 600000
104 // Number of requests in parallel we can make
105 const REQUESTS_IN_PARALLEL
= 10
107 // How many requests we put in request
108 const REQUESTS_LIMIT
= 10
110 // Number of requests to retry for replay requests module
111 const RETRY_REQUESTS
= 5
113 const REQUEST_ENDPOINTS
= {
117 // ---------------------------------------------------------------------------
119 const REMOTE_SCHEME
= {
124 // Password encryption
125 const BCRYPT_SALT_SIZE
= 10
127 // Express static paths (router)
128 const STATIC_PATHS
= {
129 PREVIEWS: '/static/previews/',
130 THUMBNAILS: '/static/thumbnails/',
131 TORRENTS: '/static/torrents/',
132 WEBSEED: '/static/webseed/'
136 let STATIC_MAX_AGE
= '30d'
138 // Videos thumbnail size
139 const THUMBNAILS_SIZE
= '200x110'
140 const PREVIEWS_SIZE
= '640x480'
147 // ---------------------------------------------------------------------------
149 // Special constants for a test instance
150 if (isTestInstance() === true) {
151 CONSTRAINTS_FIELDS
.VIDEOS
.DURATION
.max
= 14
152 FRIEND_SCORE
.BASE
= 20
153 REQUESTS_INTERVAL
= 10000
154 REMOTE_SCHEME
.HTTP
= 'http'
155 REMOTE_SCHEME
.WS
= 'ws'
159 // ---------------------------------------------------------------------------
167 LAST_MIGRATION_VERSION
,
169 PAGINATION_COUNT_DEFAULT
,
174 REQUESTS_IN_PARALLEL
,
186 // ---------------------------------------------------------------------------
188 // This method exists in utils module but we want to let the constants module independent
189 function isTestInstance () {
190 return (process
.env
.NODE_ENV
=== 'test')