aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-10-02 11:14:08 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-10-02 11:14:08 +0200
commit9f6bae3a9db13bf827f8aaff903aac06ec430903 (patch)
tree4c4735dfee42931ec0caf0de45941772b6c34312
parenta67b3e7619353d7eb1f3e6064ebe3041094a8b70 (diff)
downloadPeerTube-9f6bae3a9db13bf827f8aaff903aac06ec430903.tar.gz
PeerTube-9f6bae3a9db13bf827f8aaff903aac06ec430903.tar.zst
PeerTube-9f6bae3a9db13bf827f8aaff903aac06ec430903.zip
Server: reorganize constant file
-rw-r--r--server/initializers/constants.js111
1 files changed, 64 insertions, 47 deletions
diff --git a/server/initializers/constants.js b/server/initializers/constants.js
index 02043bd45..b1d033377 100644
--- a/server/initializers/constants.js
+++ b/server/initializers/constants.js
@@ -3,10 +3,31 @@
3const config = require('config') 3const config = require('config')
4const path = require('path') 4const path = require('path')
5 5
6// API version of our pod 6// ---------------------------------------------------------------------------
7
8// API version
7const API_VERSION = 'v1' 9const API_VERSION = 'v1'
8 10
9const BCRYPT_SALT_SIZE = 10 11// Number of results by default for the pagination
12const PAGINATION_COUNT_DEFAULT = 15
13
14// Sortable columns per schema
15const SEARCHABLE_COLUMNS = {
16 VIDEOS: [ 'name', 'magnetUri', 'podUrl', 'author', 'tags' ]
17}
18
19// Sortable columns per schema
20const SORTABLE_COLUMNS = {
21 USERS: [ 'username', '-username', 'createdDate', '-createdDate' ],
22 VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdDate', '-createdDate' ]
23}
24
25const OAUTH_LIFETIME = {
26 ACCESS_TOKEN: 3600 * 4, // 4 hours
27 REFRESH_TOKEN: 1209600 // 2 weeks
28}
29
30// ---------------------------------------------------------------------------
10 31
11const CONFIG = { 32const CONFIG = {
12 DATABASE: { 33 DATABASE: {
@@ -31,6 +52,8 @@ const CONFIG = {
31} 52}
32CONFIG.WEBSERVER.URL = CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOST + ':' + CONFIG.WEBSERVER.PORT 53CONFIG.WEBSERVER.URL = CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOST + ':' + CONFIG.WEBSERVER.PORT
33 54
55// ---------------------------------------------------------------------------
56
34const CONSTRAINTS_FIELDS = { 57const CONSTRAINTS_FIELDS = {
35 USERS: { 58 USERS: {
36 USERNAME: { min: 3, max: 20 }, // Length 59 USERNAME: { min: 3, max: 20 }, // Length
@@ -48,12 +71,16 @@ const CONSTRAINTS_FIELDS = {
48 } 71 }
49} 72}
50 73
74// ---------------------------------------------------------------------------
75
51// Score a pod has when we create it as a friend 76// Score a pod has when we create it as a friend
52const FRIEND_SCORE = { 77const FRIEND_SCORE = {
53 BASE: 100, 78 BASE: 100,
54 MAX: 1000 79 MAX: 1000
55} 80}
56 81
82// ---------------------------------------------------------------------------
83
57const MONGO_MIGRATION_SCRIPTS = [ 84const MONGO_MIGRATION_SCRIPTS = [
58 { 85 {
59 script: '0005-create-application', 86 script: '0005-create-application',
@@ -70,16 +97,7 @@ const MONGO_MIGRATION_SCRIPTS = [
70] 97]
71const LAST_MONGO_SCHEMA_VERSION = 15 98const LAST_MONGO_SCHEMA_VERSION = 15
72 99
73// Time to wait between requests to the friends (10 min) 100// ---------------------------------------------------------------------------
74let REQUESTS_INTERVAL = 600000
75
76const OAUTH_LIFETIME = {
77 ACCESS_TOKEN: 3600 * 4, // 4 hours
78 REFRESH_TOKEN: 1209600 // 2 weeks
79}
80
81// Number of results by default for the pagination
82const PAGINATION_COUNT_DEFAULT = 15
83 101
84// Number of points we add/remove from a friend after a successful/bad request 102// Number of points we add/remove from a friend after a successful/bad request
85const PODS_SCORE = { 103const PODS_SCORE = {
@@ -87,29 +105,22 @@ const PODS_SCORE = {
87 BONUS: 10 105 BONUS: 10
88} 106}
89 107
108// Time to wait between requests to the friends (10 min)
109let REQUESTS_INTERVAL = 600000
110
90// Number of requests in parallel we can make 111// Number of requests in parallel we can make
91const REQUESTS_IN_PARALLEL = 10 112const REQUESTS_IN_PARALLEL = 10
92 113
93// How many requests we put in request (request scheduler) 114// How many requests we put in request
94const REQUESTS_LIMIT = 10 115const REQUESTS_LIMIT = 10
95 116
96// Number of requests to retry for replay requests module 117// Number of requests to retry for replay requests module
97const RETRY_REQUESTS = 5 118const RETRY_REQUESTS = 5
98 119
99// Sortable columns per schema 120// ---------------------------------------------------------------------------
100const SEARCHABLE_COLUMNS = {
101 VIDEOS: [ 'name', 'magnetUri', 'podUrl', 'author', 'tags' ]
102}
103
104// Seeds in parallel we send to electron when "seed all"
105// Once a video is in seeding state we seed another video etc
106const SEEDS_IN_PARALLEL = 3
107 121
108// Sortable columns per schema 122// Password encryption
109const SORTABLE_COLUMNS = { 123const BCRYPT_SALT_SIZE = 10
110 USERS: [ 'username', '-username', 'createdDate', '-createdDate' ],
111 VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdDate', '-createdDate' ]
112}
113 124
114// Videos thumbnail size 125// Videos thumbnail size
115const THUMBNAILS_SIZE = '200x110' 126const THUMBNAILS_SIZE = '200x110'
@@ -122,36 +133,42 @@ const USER_ROLES = {
122 USER: 'user' 133 USER: 'user'
123} 134}
124 135
136// Seeds in parallel we send to electron when "seed all"
137// Once a video is in seeding state we seed another video etc
138const SEEDS_IN_PARALLEL = 3
139
140// ---------------------------------------------------------------------------
141
125// Special constants for a test instance 142// Special constants for a test instance
126if (isTestInstance() === true) { 143if (isTestInstance() === true) {
144 CONSTRAINTS_FIELDS.VIDEOS.DURATION.max = 14
127 FRIEND_SCORE.BASE = 20 145 FRIEND_SCORE.BASE = 20
128 REQUESTS_INTERVAL = 10000 146 REQUESTS_INTERVAL = 10000
129 CONSTRAINTS_FIELDS.VIDEOS.DURATION.max = 14
130} 147}
131 148
132// --------------------------------------------------------------------------- 149// ---------------------------------------------------------------------------
133 150
134module.exports = { 151module.exports = {
135 API_VERSION: API_VERSION, 152 API_VERSION,
136 BCRYPT_SALT_SIZE: BCRYPT_SALT_SIZE, 153 BCRYPT_SALT_SIZE,
137 CONFIG: CONFIG, 154 CONFIG,
138 CONSTRAINTS_FIELDS: CONSTRAINTS_FIELDS, 155 CONSTRAINTS_FIELDS,
139 FRIEND_SCORE: FRIEND_SCORE, 156 FRIEND_SCORE,
140 LAST_MONGO_SCHEMA_VERSION: LAST_MONGO_SCHEMA_VERSION, 157 LAST_MONGO_SCHEMA_VERSION,
141 MONGO_MIGRATION_SCRIPTS: MONGO_MIGRATION_SCRIPTS, 158 MONGO_MIGRATION_SCRIPTS,
142 OAUTH_LIFETIME: OAUTH_LIFETIME, 159 OAUTH_LIFETIME,
143 PAGINATION_COUNT_DEFAULT: PAGINATION_COUNT_DEFAULT, 160 PAGINATION_COUNT_DEFAULT,
144 PODS_SCORE: PODS_SCORE, 161 PODS_SCORE,
145 REQUESTS_IN_PARALLEL: REQUESTS_IN_PARALLEL, 162 REQUESTS_IN_PARALLEL,
146 REQUESTS_INTERVAL: REQUESTS_INTERVAL, 163 REQUESTS_INTERVAL,
147 REQUESTS_LIMIT: REQUESTS_LIMIT, 164 REQUESTS_LIMIT,
148 RETRY_REQUESTS: RETRY_REQUESTS, 165 RETRY_REQUESTS,
149 SEARCHABLE_COLUMNS: SEARCHABLE_COLUMNS, 166 SEARCHABLE_COLUMNS,
150 SEEDS_IN_PARALLEL: SEEDS_IN_PARALLEL, 167 SEEDS_IN_PARALLEL,
151 SORTABLE_COLUMNS: SORTABLE_COLUMNS, 168 SORTABLE_COLUMNS,
152 THUMBNAILS_SIZE: THUMBNAILS_SIZE, 169 THUMBNAILS_SIZE,
153 THUMBNAILS_STATIC_PATH: THUMBNAILS_STATIC_PATH, 170 THUMBNAILS_STATIC_PATH,
154 USER_ROLES: USER_ROLES 171 USER_ROLES
155} 172}
156 173
157// --------------------------------------------------------------------------- 174// ---------------------------------------------------------------------------