diff options
author | Chocobozzz <me@florianbigard.com> | 2020-12-14 12:00:35 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-12-14 12:00:35 +0100 |
commit | 402145b8630d1908c35f8c22846ddc4475f25d3e (patch) | |
tree | ff50cb09c5f56cc408ef20a7c959ef7a0642b76b /server/middlewares/validators/jobs.ts | |
parent | c04816108e8ec62eb29caf82806f3927dc5eb85a (diff) | |
download | PeerTube-402145b8630d1908c35f8c22846ddc4475f25d3e.tar.gz PeerTube-402145b8630d1908c35f8c22846ddc4475f25d3e.tar.zst PeerTube-402145b8630d1908c35f8c22846ddc4475f25d3e.zip |
Refactor jobs state
Diffstat (limited to 'server/middlewares/validators/jobs.ts')
-rw-r--r-- | server/middlewares/validators/jobs.ts | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/server/middlewares/validators/jobs.ts b/server/middlewares/validators/jobs.ts index 0fc183c1a..99ef25e0a 100644 --- a/server/middlewares/validators/jobs.ts +++ b/server/middlewares/validators/jobs.ts | |||
@@ -5,6 +5,10 @@ import { logger } from '../../helpers/logger' | |||
5 | import { areValidationErrors } from './utils' | 5 | import { areValidationErrors } from './utils' |
6 | 6 | ||
7 | const listJobsValidator = [ | 7 | const listJobsValidator = [ |
8 | param('state') | ||
9 | .optional() | ||
10 | .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'), | ||
11 | |||
8 | query('jobType') | 12 | query('jobType') |
9 | .optional() | 13 | .optional() |
10 | .custom(isValidJobType).withMessage('Should have a valid job state'), | 14 | .custom(isValidJobType).withMessage('Should have a valid job state'), |
@@ -18,22 +22,8 @@ const listJobsValidator = [ | |||
18 | } | 22 | } |
19 | ] | 23 | ] |
20 | 24 | ||
21 | const listJobsStateValidator = [ | ||
22 | param('state') | ||
23 | .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'), | ||
24 | |||
25 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
26 | logger.debug('Checking listJobsValidator parameters.', { parameters: req.params }) | ||
27 | |||
28 | if (areValidationErrors(req, res)) return | ||
29 | |||
30 | return next() | ||
31 | } | ||
32 | ] | ||
33 | |||
34 | // --------------------------------------------------------------------------- | 25 | // --------------------------------------------------------------------------- |
35 | 26 | ||
36 | export { | 27 | export { |
37 | listJobsValidator, | 28 | listJobsValidator |
38 | listJobsStateValidator | ||
39 | } | 29 | } |