]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/middlewares/validators/jobs.ts
fix plugin storage return value when storing a Json array
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / jobs.ts
... / ...
CommitLineData
1import express from 'express'
2import { param, query } from 'express-validator'
3import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs'
4import { logger, loggerTagsFactory } from '../../helpers/logger'
5import { areValidationErrors } from './shared'
6
7const lTags = loggerTagsFactory('validators', 'jobs')
8
9const listJobsValidator = [
10 param('state')
11 .optional()
12 .custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'),
13
14 query('jobType')
15 .optional()
16 .custom(isValidJobType).withMessage('Should have a valid job state'),
17
18 (req: express.Request, res: express.Response, next: express.NextFunction) => {
19 logger.debug('Checking listJobsValidator parameters.', { parameters: req.params, ...lTags() })
20
21 if (areValidationErrors(req, res)) return
22
23 return next()
24 }
25]
26
27// ---------------------------------------------------------------------------
28
29export {
30 listJobsValidator
31}