aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-12-04 14:49:59 +0100
committerChocobozzz <me@florianbigard.com>2019-12-04 14:49:59 +0100
commit1061c73fde3005100ead8764eacb444f240440d6 (patch)
tree0a548d7f0a9a548a52adf6d702dd589b04cd5ab0 /server/middlewares/validators
parent44df5c755c31798e64eba1ec41dd7e2d7ef50e56 (diff)
downloadPeerTube-1061c73fde3005100ead8764eacb444f240440d6.tar.gz
PeerTube-1061c73fde3005100ead8764eacb444f240440d6.tar.zst
PeerTube-1061c73fde3005100ead8764eacb444f240440d6.zip
Add ability to filter per job type
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/jobs.ts12
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 @@
1import * as express from 'express' 1import * as express from 'express'
2import { param } from 'express-validator' 2import { param, query } from 'express-validator'
3import { isValidJobState } from '../../helpers/custom-validators/jobs' 3import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
5import { areValidationErrors } from './utils' 5import { areValidationErrors } from './utils'
6 6
7const listJobsValidator = [ 7const 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