diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-09-15 12:17:08 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-09-15 12:17:08 +0200 |
commit | b60e5f38daf77e720a27aa86d3b482c58906a03a (patch) | |
tree | a70909860ab9705d348b3c082f8af440e0a5e4d2 /server/middlewares/validators/remote | |
parent | 315cc0cc1871ab2a6d6c1bb61cf7b9f10511c3a9 (diff) | |
download | PeerTube-b60e5f38daf77e720a27aa86d3b482c58906a03a.tar.gz PeerTube-b60e5f38daf77e720a27aa86d3b482c58906a03a.tar.zst PeerTube-b60e5f38daf77e720a27aa86d3b482c58906a03a.zip |
Upgrade express validator to v4
Diffstat (limited to 'server/middlewares/validators/remote')
-rw-r--r-- | server/middlewares/validators/remote/signature.ts | 18 | ||||
-rw-r--r-- | server/middlewares/validators/remote/videos.ts | 45 |
2 files changed, 38 insertions, 25 deletions
diff --git a/server/middlewares/validators/remote/signature.ts b/server/middlewares/validators/remote/signature.ts index eb5c196eb..d3937b515 100644 --- a/server/middlewares/validators/remote/signature.ts +++ b/server/middlewares/validators/remote/signature.ts | |||
@@ -1,17 +1,19 @@ | |||
1 | import 'express-validator' | 1 | import { body } from 'express-validator/check' |
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | 3 | ||
4 | import { logger } from '../../../helpers' | 4 | import { logger, isHostValid } from '../../../helpers' |
5 | import { checkErrors } from '../utils' | 5 | import { checkErrors } from '../utils' |
6 | 6 | ||
7 | function signatureValidator (req: express.Request, res: express.Response, next: express.NextFunction) { | 7 | const signatureValidator = [ |
8 | req.checkBody('signature.host', 'Should have a signature host').isURL() | 8 | body('signature.host').custom(isHostValid).withMessage('Should have a signature host'), |
9 | req.checkBody('signature.signature', 'Should have a signature').notEmpty() | 9 | body('signature.signature').not().isEmpty().withMessage('Should have a signature'), |
10 | 10 | ||
11 | logger.debug('Checking signature parameters', { parameters: { signature: req.body.signature } }) | 11 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
12 | logger.debug('Checking signature parameters', { parameters: { signature: req.body.signature } }) | ||
12 | 13 | ||
13 | checkErrors(req, res, next) | 14 | checkErrors(req, res, next) |
14 | } | 15 | } |
16 | ] | ||
15 | 17 | ||
16 | // --------------------------------------------------------------------------- | 18 | // --------------------------------------------------------------------------- |
17 | 19 | ||
diff --git a/server/middlewares/validators/remote/videos.ts b/server/middlewares/validators/remote/videos.ts index 2037c0085..e4682a60b 100644 --- a/server/middlewares/validators/remote/videos.ts +++ b/server/middlewares/validators/remote/videos.ts | |||
@@ -1,32 +1,43 @@ | |||
1 | import 'express-validator' | 1 | import { body } from 'express-validator/check' |
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | 3 | ||
4 | import { logger } from '../../../helpers' | 4 | import { |
5 | logger, | ||
6 | isEachRemoteRequestVideosValid, | ||
7 | isEachRemoteRequestVideosQaduValid, | ||
8 | isEachRemoteRequestVideosEventsValid | ||
9 | } from '../../../helpers' | ||
5 | import { checkErrors } from '../utils' | 10 | import { checkErrors } from '../utils' |
6 | 11 | ||
7 | function remoteVideosValidator (req: express.Request, res: express.Response, next: express.NextFunction) { | 12 | const remoteVideosValidator = [ |
8 | req.checkBody('data').isEachRemoteRequestVideosValid() | 13 | body('data').custom(isEachRemoteRequestVideosValid), |
9 | 14 | ||
10 | logger.debug('Checking remoteVideos parameters', { parameters: req.body }) | 15 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
16 | logger.debug('Checking remoteVideos parameters', { parameters: req.body }) | ||
11 | 17 | ||
12 | checkErrors(req, res, next) | 18 | checkErrors(req, res, next) |
13 | } | 19 | } |
20 | ] | ||
14 | 21 | ||
15 | function remoteQaduVideosValidator (req: express.Request, res: express.Response, next: express.NextFunction) { | 22 | const remoteQaduVideosValidator = [ |
16 | req.checkBody('data').isEachRemoteRequestVideosQaduValid() | 23 | body('data').custom(isEachRemoteRequestVideosQaduValid), |
17 | 24 | ||
18 | logger.debug('Checking remoteQaduVideos parameters', { parameters: req.body }) | 25 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
26 | logger.debug('Checking remoteQaduVideos parameters', { parameters: req.body }) | ||
19 | 27 | ||
20 | checkErrors(req, res, next) | 28 | checkErrors(req, res, next) |
21 | } | 29 | } |
30 | ] | ||
22 | 31 | ||
23 | function remoteEventsVideosValidator (req: express.Request, res: express.Response, next: express.NextFunction) { | 32 | const remoteEventsVideosValidator = [ |
24 | req.checkBody('data').isEachRemoteRequestVideosEventsValid() | 33 | body('data').custom(isEachRemoteRequestVideosEventsValid), |
25 | 34 | ||
26 | logger.debug('Checking remoteEventsVideos parameters', { parameters: req.body }) | 35 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
36 | logger.debug('Checking remoteEventsVideos parameters', { parameters: req.body }) | ||
27 | 37 | ||
28 | checkErrors(req, res, next) | 38 | checkErrors(req, res, next) |
29 | } | 39 | } |
40 | ] | ||
30 | 41 | ||
31 | // --------------------------------------------------------------------------- | 42 | // --------------------------------------------------------------------------- |
32 | 43 | ||