]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/middlewares/validators/jobs.ts
feature/ability to disable video history by default (#5728)
[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 { 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),
13
14 query('jobType')
15 .optional()
16 .custom(isValidJobType),
17
18 (req: express.Request, res: express.Response, next: express.NextFunction) => {
19 if (areValidationErrors(req, res, lTags())) return
20
21 return next()
22 }
23]
24
25// ---------------------------------------------------------------------------
26
27export {
28 listJobsValidator
29}