]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/middlewares/validators/jobs.ts
Split ffmpeg utils with ffprobe utils
[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 = [
1061c73f
C
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'),
94a5ff8a 13
1061c73f 14 (req: express.Request, res: express.Response, next: express.NextFunction) => {
94a5ff8a
C
15 logger.debug('Checking listJobsValidator parameters.', { parameters: req.params })
16
17 if (areValidationErrors(req, res)) return
18
19 return next()
20 }
21]
22
23// ---------------------------------------------------------------------------
24
25export {
26 listJobsValidator
27}