aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-17 10:32:03 +0100
committerChocobozzz <me@florianbigard.com>2018-01-17 10:41:27 +0100
commitfd206f0b2d7e5c8e00e2817266d90ec54f79e1da (patch)
tree86b096cf2abd7eb49b892de1c9be855f45a41a9c /server/middlewares/validators
parent9581cabc596acb18c0ad86bcf3a07c2b45e8e47e (diff)
downloadPeerTube-fd206f0b2d7e5c8e00e2817266d90ec54f79e1da.tar.gz
PeerTube-fd206f0b2d7e5c8e00e2817266d90ec54f79e1da.tar.zst
PeerTube-fd206f0b2d7e5c8e00e2817266d90ec54f79e1da.zip
Add ability to update some configuration keys
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/config.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts
new file mode 100644
index 000000000..800aaf107
--- /dev/null
+++ b/server/middlewares/validators/config.ts
@@ -0,0 +1,32 @@
1import * as express from 'express'
2import { body } from 'express-validator/check'
3import { isUserVideoQuotaValid } from '../../helpers/custom-validators/users'
4import { logger } from '../../helpers/logger'
5import { areValidationErrors } from './utils'
6
7const customConfigUpdateValidator = [
8 body('cache.previews.size').isInt().withMessage('Should have a valid previews size'),
9 body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'),
10 body('signup.limit').isInt().withMessage('Should have a valid signup limit'),
11 body('admin.email').isEmail().withMessage('Should have a valid administrator email'),
12 body('user.videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid video quota'),
13 body('transcoding.enabled').isBoolean().withMessage('Should have a valid transcoding enabled boolean'),
14 body('transcoding.threads').isInt().withMessage('Should have a valid transcoding threads number'),
15 body('transcoding.resolutions.240p').isBoolean().withMessage('Should have a valid transcoding 240p resolution enabled boolean'),
16 body('transcoding.resolutions.360p').isBoolean().withMessage('Should have a valid transcoding 360p resolution enabled boolean'),
17 body('transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'),
18 body('transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'),
19 body('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'),
20
21 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
22 logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body })
23
24 if (areValidationErrors(req, res)) return
25
26 return next()
27 }
28]
29
30export {
31 customConfigUpdateValidator
32}