aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/config.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/config.ts')
-rw-r--r--server/middlewares/validators/config.ts186
1 files changed, 92 insertions, 94 deletions
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts
index f60103f48..c89f3087e 100644
--- a/server/middlewares/validators/config.ts
+++ b/server/middlewares/validators/config.ts
@@ -11,100 +11,98 @@ import { areValidationErrors } from './shared'
11import { HttpStatusCode } from '@shared/models/http/http-error-codes' 11import { HttpStatusCode } from '@shared/models/http/http-error-codes'
12 12
13const customConfigUpdateValidator = [ 13const customConfigUpdateValidator = [
14 body('instance.name').exists().withMessage('Should have a valid instance name'), 14 body('instance.name').exists(),
15 body('instance.shortDescription').exists().withMessage('Should have a valid instance short description'), 15 body('instance.shortDescription').exists(),
16 body('instance.description').exists().withMessage('Should have a valid instance description'), 16 body('instance.description').exists(),
17 body('instance.terms').exists().withMessage('Should have a valid instance terms'), 17 body('instance.terms').exists(),
18 body('instance.defaultNSFWPolicy').custom(isUserNSFWPolicyValid).withMessage('Should have a valid NSFW policy'), 18 body('instance.defaultNSFWPolicy').custom(isUserNSFWPolicyValid),
19 body('instance.defaultClientRoute').exists().withMessage('Should have a valid instance default client route'), 19 body('instance.defaultClientRoute').exists(),
20 body('instance.customizations.css').exists().withMessage('Should have a valid instance CSS customization'), 20 body('instance.customizations.css').exists(),
21 body('instance.customizations.javascript').exists().withMessage('Should have a valid instance JavaScript customization'), 21 body('instance.customizations.javascript').exists(),
22 22
23 body('services.twitter.username').exists().withMessage('Should have a valid twitter username'), 23 body('services.twitter.username').exists(),
24 body('services.twitter.whitelisted').isBoolean().withMessage('Should have a valid twitter whitelisted boolean'), 24 body('services.twitter.whitelisted').isBoolean(),
25 25
26 body('cache.previews.size').isInt().withMessage('Should have a valid previews cache size'), 26 body('cache.previews.size').isInt(),
27 body('cache.captions.size').isInt().withMessage('Should have a valid captions cache size'), 27 body('cache.captions.size').isInt(),
28 body('cache.torrents.size').isInt().withMessage('Should have a valid torrents cache size'), 28 body('cache.torrents.size').isInt(),
29 29
30 body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'), 30 body('signup.enabled').isBoolean(),
31 body('signup.limit').isInt().withMessage('Should have a valid signup limit'), 31 body('signup.limit').isInt(),
32 body('signup.requiresEmailVerification').isBoolean().withMessage('Should have a valid requiresEmailVerification boolean'), 32 body('signup.requiresEmailVerification').isBoolean(),
33 body('signup.minimumAge').isInt().withMessage('Should have a valid minimum age required'), 33 body('signup.minimumAge').isInt(),
34 34
35 body('admin.email').isEmail().withMessage('Should have a valid administrator email'), 35 body('admin.email').isEmail(),
36 body('contactForm.enabled').isBoolean().withMessage('Should have a valid contact form enabled boolean'), 36 body('contactForm.enabled').isBoolean(),
37 37
38 body('user.videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid video quota'), 38 body('user.videoQuota').custom(isUserVideoQuotaValid),
39 body('user.videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily video quota'), 39 body('user.videoQuotaDaily').custom(isUserVideoQuotaDailyValid),
40 40
41 body('videoChannels.maxPerUser').isInt().withMessage('Should have a valid maximum amount of video channels per user'), 41 body('videoChannels.maxPerUser').isInt(),
42 42
43 body('transcoding.enabled').isBoolean().withMessage('Should have a valid transcoding enabled boolean'), 43 body('transcoding.enabled').isBoolean(),
44 body('transcoding.allowAdditionalExtensions').isBoolean().withMessage('Should have a valid additional extensions boolean'), 44 body('transcoding.allowAdditionalExtensions').isBoolean(),
45 body('transcoding.threads').isInt().withMessage('Should have a valid transcoding threads number'), 45 body('transcoding.threads').isInt(),
46 body('transcoding.concurrency').isInt({ min: 1 }).withMessage('Should have a valid transcoding concurrency number'), 46 body('transcoding.concurrency').isInt({ min: 1 }),
47 body('transcoding.resolutions.0p').isBoolean().withMessage('Should have a valid transcoding 0p resolution enabled boolean'), 47 body('transcoding.resolutions.0p').isBoolean(),
48 body('transcoding.resolutions.144p').isBoolean().withMessage('Should have a valid transcoding 144p resolution enabled boolean'), 48 body('transcoding.resolutions.144p').isBoolean(),
49 body('transcoding.resolutions.240p').isBoolean().withMessage('Should have a valid transcoding 240p resolution enabled boolean'), 49 body('transcoding.resolutions.240p').isBoolean(),
50 body('transcoding.resolutions.360p').isBoolean().withMessage('Should have a valid transcoding 360p resolution enabled boolean'), 50 body('transcoding.resolutions.360p').isBoolean(),
51 body('transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'), 51 body('transcoding.resolutions.480p').isBoolean(),
52 body('transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'), 52 body('transcoding.resolutions.720p').isBoolean(),
53 body('transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), 53 body('transcoding.resolutions.1080p').isBoolean(),
54 body('transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'), 54 body('transcoding.resolutions.1440p').isBoolean(),
55 body('transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'), 55 body('transcoding.resolutions.2160p').isBoolean(),
56 56
57 body('transcoding.alwaysTranscodeOriginalResolution').isBoolean() 57 body('transcoding.alwaysTranscodeOriginalResolution').isBoolean(),
58 .withMessage('Should have a valid always transcode original resolution boolean'), 58
59 59 body('transcoding.webtorrent.enabled').isBoolean(),
60 body('transcoding.webtorrent.enabled').isBoolean().withMessage('Should have a valid webtorrent transcoding enabled boolean'), 60 body('transcoding.hls.enabled').isBoolean(),
61 body('transcoding.hls.enabled').isBoolean().withMessage('Should have a valid hls transcoding enabled boolean'), 61
62 62 body('videoStudio.enabled').isBoolean(),
63 body('videoStudio.enabled').isBoolean().withMessage('Should have a valid video studio enabled boolean'), 63
64 64 body('import.videos.concurrency').isInt({ min: 0 }),
65 body('import.videos.concurrency').isInt({ min: 0 }).withMessage('Should have a valid import concurrency number'), 65 body('import.videos.http.enabled').isBoolean(),
66 body('import.videos.http.enabled').isBoolean().withMessage('Should have a valid import video http enabled boolean'), 66 body('import.videos.torrent.enabled').isBoolean(),
67 body('import.videos.torrent.enabled').isBoolean().withMessage('Should have a valid import video torrent enabled boolean'), 67
68 68 body('import.videoChannelSynchronization.enabled').isBoolean(),
69 body('import.videoChannelSynchronization.enabled').isBoolean().withMessage('Should have a valid synchronization enabled boolean'), 69
70 70 body('trending.videos.algorithms.default').exists(),
71 body('trending.videos.algorithms.default').exists().withMessage('Should have a valid default trending algorithm'), 71 body('trending.videos.algorithms.enabled').exists(),
72 body('trending.videos.algorithms.enabled').exists().withMessage('Should have a valid array of enabled trending algorithms'), 72
73 73 body('followers.instance.enabled').isBoolean(),
74 body('followers.instance.enabled').isBoolean().withMessage('Should have a valid followers of instance boolean'), 74 body('followers.instance.manualApproval').isBoolean(),
75 body('followers.instance.manualApproval').isBoolean().withMessage('Should have a valid manual approval boolean'), 75
76 76 body('theme.default').custom(v => isThemeNameValid(v) && isThemeRegistered(v)),
77 body('theme.default').custom(v => isThemeNameValid(v) && isThemeRegistered(v)).withMessage('Should have a valid theme'), 77
78 78 body('broadcastMessage.enabled').isBoolean(),
79 body('broadcastMessage.enabled').isBoolean().withMessage('Should have a valid broadcast message enabled boolean'), 79 body('broadcastMessage.message').exists(),
80 body('broadcastMessage.message').exists().withMessage('Should have a valid broadcast message'), 80 body('broadcastMessage.level').exists(),
81 body('broadcastMessage.level').exists().withMessage('Should have a valid broadcast level'), 81 body('broadcastMessage.dismissable').isBoolean(),
82 body('broadcastMessage.dismissable').isBoolean().withMessage('Should have a valid broadcast dismissable boolean'), 82
83 83 body('live.enabled').isBoolean(),
84 body('live.enabled').isBoolean().withMessage('Should have a valid live enabled boolean'), 84 body('live.allowReplay').isBoolean(),
85 body('live.allowReplay').isBoolean().withMessage('Should have a valid live allow replay boolean'), 85 body('live.maxDuration').isInt(),
86 body('live.maxDuration').isInt().withMessage('Should have a valid live max duration'), 86 body('live.maxInstanceLives').custom(isIntOrNull),
87 body('live.maxInstanceLives').custom(isIntOrNull).withMessage('Should have a valid max instance lives'), 87 body('live.maxUserLives').custom(isIntOrNull),
88 body('live.maxUserLives').custom(isIntOrNull).withMessage('Should have a valid max user lives'), 88 body('live.transcoding.enabled').isBoolean(),
89 body('live.transcoding.enabled').isBoolean().withMessage('Should have a valid live transcoding enabled boolean'), 89 body('live.transcoding.threads').isInt(),
90 body('live.transcoding.threads').isInt().withMessage('Should have a valid live transcoding threads'), 90 body('live.transcoding.resolutions.144p').isBoolean(),
91 body('live.transcoding.resolutions.144p').isBoolean().withMessage('Should have a valid transcoding 144p resolution enabled boolean'), 91 body('live.transcoding.resolutions.240p').isBoolean(),
92 body('live.transcoding.resolutions.240p').isBoolean().withMessage('Should have a valid transcoding 240p resolution enabled boolean'), 92 body('live.transcoding.resolutions.360p').isBoolean(),
93 body('live.transcoding.resolutions.360p').isBoolean().withMessage('Should have a valid transcoding 360p resolution enabled boolean'), 93 body('live.transcoding.resolutions.480p').isBoolean(),
94 body('live.transcoding.resolutions.480p').isBoolean().withMessage('Should have a valid transcoding 480p resolution enabled boolean'), 94 body('live.transcoding.resolutions.720p').isBoolean(),
95 body('live.transcoding.resolutions.720p').isBoolean().withMessage('Should have a valid transcoding 720p resolution enabled boolean'), 95 body('live.transcoding.resolutions.1080p').isBoolean(),
96 body('live.transcoding.resolutions.1080p').isBoolean().withMessage('Should have a valid transcoding 1080p resolution enabled boolean'), 96 body('live.transcoding.resolutions.1440p').isBoolean(),
97 body('live.transcoding.resolutions.1440p').isBoolean().withMessage('Should have a valid transcoding 1440p resolution enabled boolean'), 97 body('live.transcoding.resolutions.2160p').isBoolean(),
98 body('live.transcoding.resolutions.2160p').isBoolean().withMessage('Should have a valid transcoding 2160p resolution enabled boolean'), 98 body('live.transcoding.alwaysTranscodeOriginalResolution').isBoolean(),
99 body('live.transcoding.alwaysTranscodeOriginalResolution').isBoolean() 99
100 .withMessage('Should have a valid always transcode live original resolution boolean'), 100 body('search.remoteUri.users').isBoolean(),
101 101 body('search.remoteUri.anonymous').isBoolean(),
102 body('search.remoteUri.users').isBoolean().withMessage('Should have a remote URI search for users boolean'), 102 body('search.searchIndex.enabled').isBoolean(),
103 body('search.remoteUri.anonymous').isBoolean().withMessage('Should have a valid remote URI search for anonymous boolean'), 103 body('search.searchIndex.url').exists(),
104 body('search.searchIndex.enabled').isBoolean().withMessage('Should have a valid search index enabled boolean'), 104 body('search.searchIndex.disableLocalSearch').isBoolean(),
105 body('search.searchIndex.url').exists().withMessage('Should have a valid search index URL'), 105 body('search.searchIndex.isDefaultSearch').isBoolean(),
106 body('search.searchIndex.disableLocalSearch').isBoolean().withMessage('Should have a valid search index disable local search boolean'),
107 body('search.searchIndex.isDefaultSearch').isBoolean().withMessage('Should have a valid search index default enabled boolean'),
108 106
109 (req: express.Request, res: express.Response, next: express.NextFunction) => { 107 (req: express.Request, res: express.Response, next: express.NextFunction) => {
110 logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body }) 108 logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body })