]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/middlewares/validators/jobs.ts
Use named chunk for embed on analyze
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / jobs.ts
... / ...
CommitLineData
1import * as express from 'express'
2import { param, query } from 'express-validator'
3import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs'
4import { logger } from '../../helpers/logger'
5import { areValidationErrors } from './utils'
6
7const listJobsValidator = [
8 param('state')
9 .optional()
10 .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'),
11
12 query('jobType')
13 .optional()
14 .custom(isValidJobType).withMessage('Should have a valid job state'),
15
16 (req: express.Request, res: express.Response, next: express.NextFunction) => {
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 {
28 listJobsValidator
29}