]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/middlewares/validators/jobs.ts
Use named chunk for embed on analyze
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / jobs.ts
CommitLineData
94a5ff8a 1import * as express from 'express'
1061c73f
C
2import { param, query } from 'express-validator'
3import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs'
94a5ff8a
C
4import { logger } from '../../helpers/logger'
5import { areValidationErrors } from './utils'
6
7const listJobsValidator = [
402145b8
C
8 param('state')
9 .optional()
10 .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'),
11
1061c73f
C
12 query('jobType')
13 .optional()
14 .custom(isValidJobType).withMessage('Should have a valid job state'),
94a5ff8a 15
1061c73f 16 (req: express.Request, res: express.Response, next: express.NextFunction) => {
94a5ff8a
C
17 logger.debug('Checking listJobsValidator parameters.', { parameters: req.params })
18
19 if (areValidationErrors(req, res)) return
20
21 return next()
22 }
23]
24
25// ---------------------------------------------------------------------------
26
27export {
402145b8 28 listJobsValidator
94a5ff8a 29}