X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Fjobs.ts;h=e5008adc3650657c6488a21ff35b11e136de272f;hb=05a60d85997c108d39bcfb14f1ffd4c74f8b1e93;hp=2f8b1738c5054552b782aa359a646929153a19fb;hpb=94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/jobs.ts b/server/middlewares/validators/jobs.ts index 2f8b1738c..e5008adc3 100644 --- a/server/middlewares/validators/jobs.ts +++ b/server/middlewares/validators/jobs.ts @@ -1,16 +1,22 @@ -import * as express from 'express' -import { param } from 'express-validator/check' -import { isValidJobState } from '../../helpers/custom-validators/jobs' -import { logger } from '../../helpers/logger' -import { areValidationErrors } from './utils' +import express from 'express' +import { param, query } from 'express-validator' +import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs' +import { loggerTagsFactory } from '../../helpers/logger' +import { areValidationErrors } from './shared' + +const lTags = loggerTagsFactory('validators', 'jobs') const listJobsValidator = [ - param('state').custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'), + param('state') + .optional() + .custom(isValidJobState), - async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking listJobsValidator parameters.', { parameters: req.params }) + query('jobType') + .optional() + .custom(isValidJobType), - if (areValidationErrors(req, res)) return + (req: express.Request, res: express.Response, next: express.NextFunction) => { + if (areValidationErrors(req, res, lTags())) return return next() }