]>
Commit | Line | Data |
---|---|---|
fd206f0b C |
1 | import * as express from 'express' |
2 | import { body } from 'express-validator/check' | |
0883b324 | 3 | import { isUserNSFWPolicyValid, isUserVideoQuotaValid } from '../../helpers/custom-validators/users' |
fd206f0b C |
4 | import { logger } from '../../helpers/logger' |
5 | import { areValidationErrors } from './utils' | |
6 | ||
7 | const customConfigUpdateValidator = [ | |
901637bb C |
8 | body('instance.name').exists().withMessage('Should have a valid instance name'), |
9 | body('instance.description').exists().withMessage('Should have a valid instance description'), | |
10 | body('instance.terms').exists().withMessage('Should have a valid instance terms'), | |
11 | body('instance.defaultClientRoute').exists().withMessage('Should have a valid instance default client route'), | |
0883b324 | 12 | body('instance.defaultNSFWPolicy').custom(isUserNSFWPolicyValid).withMessage('Should have a valid NSFW policy'), |
901637bb C |
13 | body('instance.customizations.css').exists().withMessage('Should have a valid instance CSS customization'), |
14 | body('instance.customizations.javascript').exists().withMessage('Should have a valid instance JavaScript customization'), | |
fd206f0b C |
15 | body('cache.previews.size').isInt().withMessage('Should have a valid previews size'), |
16 | body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'), | |
17 | body('signup.limit').isInt().withMessage('Should have a valid signup limit'), | |
18 | body('admin.email').isEmail().withMessage('Should have a valid administrator email'), | |
19 | body('user.videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid video quota'), | |
20 | body('transcoding.enabled').isBoolean().withMessage('Should have a valid transcoding enabled boolean'), | |
21 | body('transcoding.threads').isInt().withMessage('Should have a valid transcoding threads number'), | |
22 | body('transcoding.resolutions.240p').isBoolean().withMessage('Should have a valid transcoding 240p resolution enabled boolean'), | |
23 | body('transcoding.resolutions.360p').isBoolean().withMessage('Should have a valid transcoding 360p resolution enabled boolean'), | |
24 | body('transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'), | |
25 | body('transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'), | |
26 | body('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), | |
5d08a6a7 | 27 | body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'), |
a84b8fa5 | 28 | body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'), |
fd206f0b C |
29 | |
30 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | |
31 | logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body }) | |
32 | ||
33 | if (areValidationErrors(req, res)) return | |
34 | ||
35 | return next() | |
36 | } | |
37 | ] | |
38 | ||
39 | export { | |
40 | customConfigUpdateValidator | |
41 | } |