jobs.ts 756 B

1234567891011121314151617181920212223242526272829
  1. import express from 'express'
  2. import { param, query } from 'express-validator'
  3. import { isValidJobState, isValidJobType } from '../../helpers/custom-validators/jobs'
  4. import { loggerTagsFactory } from '../../helpers/logger'
  5. import { areValidationErrors } from './shared'
  6. const lTags = loggerTagsFactory('validators', 'jobs')
  7. const listJobsValidator = [
  8. param('state')
  9. .optional()
  10. .custom(isValidJobState),
  11. query('jobType')
  12. .optional()
  13. .custom(isValidJobType),
  14. (req: express.Request, res: express.Response, next: express.NextFunction) => {
  15. if (areValidationErrors(req, res, lTags())) return
  16. return next()
  17. }
  18. ]
  19. // ---------------------------------------------------------------------------
  20. export {
  21. listJobsValidator
  22. }