diff options
author | Chocobozzz <me@florianbigard.com> | 2019-12-04 14:49:59 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-12-04 14:49:59 +0100 |
commit | 1061c73fde3005100ead8764eacb444f240440d6 (patch) | |
tree | 0a548d7f0a9a548a52adf6d702dd589b04cd5ab0 /server/middlewares/validators/jobs.ts | |
parent | 44df5c755c31798e64eba1ec41dd7e2d7ef50e56 (diff) | |
download | PeerTube-1061c73fde3005100ead8764eacb444f240440d6.tar.gz PeerTube-1061c73fde3005100ead8764eacb444f240440d6.tar.zst PeerTube-1061c73fde3005100ead8764eacb444f240440d6.zip |
Add ability to filter per job type
Diffstat (limited to 'server/middlewares/validators/jobs.ts')
-rw-r--r-- | server/middlewares/validators/jobs.ts | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/server/middlewares/validators/jobs.ts b/server/middlewares/validators/jobs.ts index 41a8d6899..b57615dbc 100644 --- a/server/middlewares/validators/jobs.ts +++ b/server/middlewares/validators/jobs.ts | |||
@@ -1,13 +1,17 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { param } from 'express-validator' | 2 | import { param, query } from 'express-validator' |
3 | import { isValidJobState } from '../../helpers/custom-validators/jobs' | 3 | import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs' |
4 | import { logger } from '../../helpers/logger' | 4 | 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').custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'), | 8 | param('state') |
9 | .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'), | ||
10 | query('jobType') | ||
11 | .optional() | ||
12 | .custom(isValidJobType).withMessage('Should have a valid job state'), | ||
9 | 13 | ||
10 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 14 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
11 | logger.debug('Checking listJobsValidator parameters.', { parameters: req.params }) | 15 | logger.debug('Checking listJobsValidator parameters.', { parameters: req.params }) |
12 | 16 | ||
13 | if (areValidationErrors(req, res)) return | 17 | if (areValidationErrors(req, res)) return |