jobs.ts 737 B

1234567891011121314151617181920212223
  1. import * as express from 'express'
  2. import { param } from 'express-validator/check'
  3. import { isValidJobState } from '../../helpers/custom-validators/jobs'
  4. import { logger } from '../../helpers/logger'
  5. import { areValidationErrors } from './utils'
  6. const listJobsValidator = [
  7. param('state').custom(isValidJobState).not().isEmpty().withMessage('Should have a valid job state'),
  8. async (req: express.Request, res: express.Response, next: express.NextFunction) => {
  9. logger.debug('Checking listJobsValidator parameters.', { parameters: req.params })
  10. if (areValidationErrors(req, res)) return
  11. return next()
  12. }
  13. ]
  14. // ---------------------------------------------------------------------------
  15. export {
  16. listJobsValidator
  17. }