]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/initializers/constants.js
3 const config
= require('config')
4 const path
= require('path')
6 // API version of our pod
7 const API_VERSION
= 'v1'
11 DBNAME: 'peertube' + config
.get('database.suffix'),
12 HOST: config
.get('database.host'),
13 PORT: config
.get('database.port')
16 DEBUG: config
.get('electron.debug')
19 CERT_DIR: path
.join(__dirname
, '..', '..', config
.get('storage.certs')),
20 LOG_DIR: path
.join(__dirname
, '..', '..', config
.get('storage.logs')),
21 UPLOAD_DIR: path
.join(__dirname
, '..', '..', config
.get('storage.uploads')),
22 THUMBNAILS_DIR: path
.join(__dirname
, '..', '..', config
.get('storage.thumbnails'))
25 SCHEME: config
.get('webserver.https') === true ? 'https' : 'http',
26 HOST: config
.get('webserver.host'),
27 PORT: config
.get('webserver.port')
30 CONFIG
.WEBSERVER
.URL
= CONFIG
.WEBSERVER
.SCHEME
+ '://' + CONFIG
.WEBSERVER
.HOST
+ ':' + CONFIG
.WEBSERVER
.PORT
32 const CONSTRAINTS_FIELDS
= {
34 USERNAME: { min: 3, max: 20 }, // Length
35 PASSWORD: { min: 6, max: 255 } // Length
38 NAME: { min: 3, max: 50 }, // Length
39 DESCRIPTION: { min: 3, max: 250 }, // Length
40 MAGNET_URI: { min: 10 }, // Length
41 DURATION: { min: 1, max: 7200 }, // Number
42 TAGS: { min: 1, max: 3 }, // Number of total tags
43 TAG: { min: 2, max: 10 }, // Length
44 THUMBNAIL: { min: 2, max: 30 },
45 THUMBNAIL64: { min: 0, max: 20000 } // Bytes
49 // Score a pod has when we create it as a friend
50 const FRIEND_SCORE
= {
55 // Time to wait between requests to the friends (10 min)
58 const OAUTH_LIFETIME
= {
59 ACCESS_TOKEN: 3600 * 4, // 4 hours
60 REFRESH_TOKEN: 1209600 // 2 weeks
63 // Number of results by default for the pagination
64 const PAGINATION_COUNT_DEFAULT
= 15
66 // Number of points we add/remove from a friend after a successful/bad request
72 // Number of requests in parallel we can make
73 const REQUESTS_IN_PARALLEL
= 10
75 // How many requests we put in request (request scheduler)
76 const REQUESTS_LIMIT
= 10
78 // Number of requests to retry for replay requests module
79 const RETRY_REQUESTS
= 5
81 // Sortable columns per schema
82 const SEARCHABLE_COLUMNS
= {
83 VIDEOS: [ 'name', 'magnetUri', 'podUrl', 'author', 'tags' ]
86 // Seeds in parallel we send to electron when "seed all"
87 // Once a video is in seeding state we seed another video etc
88 const SEEDS_IN_PARALLEL
= 3
90 // Sortable columns per schema
91 const SORTABLE_COLUMNS
= {
92 USERS: [ 'username', '-username', 'createdDate', '-createdDate' ],
93 VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdDate', '-createdDate' ]
96 // Videos thumbnail size
97 const THUMBNAILS_SIZE
= '200x110'
99 // Path for access to thumbnails with express router
100 const THUMBNAILS_STATIC_PATH
= '/static/thumbnails'
107 // Special constants for a test instance
108 if (isTestInstance() === true) {
109 FRIEND_SCORE
.BASE
= 20
111 CONSTRAINTS_FIELDS
.VIDEOS
.DURATION
.max
= 14
114 // ---------------------------------------------------------------------------
117 API_VERSION: API_VERSION
,
119 CONSTRAINTS_FIELDS: CONSTRAINTS_FIELDS
,
120 FRIEND_SCORE: FRIEND_SCORE
,
122 OAUTH_LIFETIME: OAUTH_LIFETIME
,
123 PAGINATION_COUNT_DEFAULT: PAGINATION_COUNT_DEFAULT
,
124 PODS_SCORE: PODS_SCORE
,
125 REQUESTS_IN_PARALLEL: REQUESTS_IN_PARALLEL
,
126 REQUESTS_LIMIT: REQUESTS_LIMIT
,
127 RETRY_REQUESTS: RETRY_REQUESTS
,
128 SEARCHABLE_COLUMNS: SEARCHABLE_COLUMNS
,
129 SEEDS_IN_PARALLEL: SEEDS_IN_PARALLEL
,
130 SORTABLE_COLUMNS: SORTABLE_COLUMNS
,
131 THUMBNAILS_SIZE: THUMBNAILS_SIZE
,
132 THUMBNAILS_STATIC_PATH: THUMBNAILS_STATIC_PATH
,
133 USER_ROLES: USER_ROLES
136 // ---------------------------------------------------------------------------
138 function isTestInstance () {
139 return (process
.env
.NODE_ENV
=== 'test')