aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-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}