aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/constants.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-07-31 20:58:43 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-07-31 20:58:43 +0200
commite4c556196d7b31111f17596840d2e1d60caa7dcb (patch)
tree41be84f002600aa0153ac09cc5d79fdd90d126e3 /server/initializers/constants.js
parente62f6ef741c8d14817e321c554796ad64ea7ae1b (diff)
downloadPeerTube-e4c556196d7b31111f17596840d2e1d60caa7dcb.tar.gz
PeerTube-e4c556196d7b31111f17596840d2e1d60caa7dcb.tar.zst
PeerTube-e4c556196d7b31111f17596840d2e1d60caa7dcb.zip
Server: reorganize express validators
Diffstat (limited to 'server/initializers/constants.js')
-rw-r--r--server/initializers/constants.js35
1 files changed, 20 insertions, 15 deletions
diff --git a/server/initializers/constants.js b/server/initializers/constants.js
index 467816f2c..5f4aeccc6 100644
--- a/server/initializers/constants.js
+++ b/server/initializers/constants.js
@@ -3,6 +3,23 @@
3// API version of our pod 3// API version of our pod
4const API_VERSION = 'v1' 4const API_VERSION = 'v1'
5 5
6const CONSTRAINTS_FIELDS = {
7 USERS: {
8 USERNAME: { min: 3, max: 20 }, // Length
9 PASSWORD: { min: 6, max: 255 } // Length
10 },
11 VIDEOS: {
12 NAME: { min: 3, max: 50 }, // Length
13 DESCRIPTION: { min: 3, max: 250 }, // Length
14 MAGNET_URI: { min: 10 }, // Length
15 DURATION: { min: 1, max: 7200 }, // Number
16 TAGS: { min: 1, max: 3 }, // Number of total tags
17 TAG: { min: 2, max: 10 }, // Length
18 THUMBNAIL: { min: 2, max: 30 },
19 THUMBNAIL64: { min: 0, max: 20000 } // Bytes
20 }
21}
22
6// Score a pod has when we create it as a friend 23// Score a pod has when we create it as a friend
7const FRIEND_SCORE = { 24const FRIEND_SCORE = {
8 BASE: 100, 25 BASE: 100,
@@ -55,29 +72,18 @@ const THUMBNAILS_SIZE = '200x110'
55// Path for access to thumbnails with express router 72// Path for access to thumbnails with express router
56const THUMBNAILS_STATIC_PATH = '/static/thumbnails' 73const THUMBNAILS_STATIC_PATH = '/static/thumbnails'
57 74
58const VIDEOS_CONSTRAINTS_FIELDS = {
59 NAME: { min: 3, max: 50 }, // Length
60 DESCRIPTION: { min: 3, max: 250 }, // Length
61 MAGNET_URI: { min: 10 }, // Length
62 DURATION: { min: 1, max: 7200 }, // Number
63 AUTHOR: { min: 3, max: 20 }, // Length
64 TAGS: { min: 1, max: 3 }, // Number of total tags
65 TAG: { min: 2, max: 10 }, // Length
66 THUMBNAIL: { min: 2, max: 30 },
67 THUMBNAIL64: { min: 0, max: 20000 } // Bytes
68}
69
70// Special constants for a test instance 75// Special constants for a test instance
71if (isTestInstance() === true) { 76if (isTestInstance() === true) {
72 FRIEND_SCORE.BASE = 20 77 FRIEND_SCORE.BASE = 20
73 INTERVAL = 10000 78 INTERVAL = 10000
74 VIDEOS_CONSTRAINTS_FIELDS.DURATION.max = 14 79 CONSTRAINTS_FIELDS.VIDEOS.DURATION.max = 14
75} 80}
76 81
77// --------------------------------------------------------------------------- 82// ---------------------------------------------------------------------------
78 83
79module.exports = { 84module.exports = {
80 API_VERSION: API_VERSION, 85 API_VERSION: API_VERSION,
86 CONSTRAINTS_FIELDS: CONSTRAINTS_FIELDS,
81 FRIEND_SCORE: FRIEND_SCORE, 87 FRIEND_SCORE: FRIEND_SCORE,
82 INTERVAL: INTERVAL, 88 INTERVAL: INTERVAL,
83 OAUTH_LIFETIME: OAUTH_LIFETIME, 89 OAUTH_LIFETIME: OAUTH_LIFETIME,
@@ -90,8 +96,7 @@ module.exports = {
90 SEEDS_IN_PARALLEL: SEEDS_IN_PARALLEL, 96 SEEDS_IN_PARALLEL: SEEDS_IN_PARALLEL,
91 SORTABLE_COLUMNS: SORTABLE_COLUMNS, 97 SORTABLE_COLUMNS: SORTABLE_COLUMNS,
92 THUMBNAILS_SIZE: THUMBNAILS_SIZE, 98 THUMBNAILS_SIZE: THUMBNAILS_SIZE,
93 THUMBNAILS_STATIC_PATH: THUMBNAILS_STATIC_PATH, 99 THUMBNAILS_STATIC_PATH: THUMBNAILS_STATIC_PATH
94 VIDEOS_CONSTRAINTS_FIELDS: VIDEOS_CONSTRAINTS_FIELDS
95} 100}
96 101
97// --------------------------------------------------------------------------- 102// ---------------------------------------------------------------------------