1 import * as express from 'express'
2 import { areValidationErrors } from './utils'
3 import { logger } from '../../helpers/logger'
4 import { query } from 'express-validator/check'
5 import { isDateValid } from '../../helpers/custom-validators/misc'
7 const videosSearchValidator = [
8 query('search').optional().not().isEmpty().withMessage('Should have a valid search'),
10 query('startDate').optional().custom(isDateValid).withMessage('Should have a valid start date'),
11 query('endDate').optional().custom(isDateValid).withMessage('Should have a valid end date'),
13 query('durationMin').optional().isInt().withMessage('Should have a valid min duration'),
14 query('durationMax').optional().isInt().withMessage('Should have a valid max duration'),
16 (req: express.Request, res: express.Response, next: express.NextFunction) => {
17 logger.debug('Checking videos search query', { parameters: req.query })
19 if (areValidationErrors(req, res)) return
25 const videoChannelsSearchValidator = [
26 query('search').not().isEmpty().withMessage('Should have a valid search'),
28 (req: express.Request, res: express.Response, next: express.NextFunction) => {
29 logger.debug('Checking video channels search query', { parameters: req.query })
31 if (areValidationErrors(req, res)) return
37 // ---------------------------------------------------------------------------
40 videoChannelsSearchValidator,