1 import * as express from 'express'
2 import { areValidationErrors } from './utils'
3 import { logger } from '../../helpers/logger'
4 import { query } from 'express-validator'
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('originallyPublishedStartDate').optional().custom(isDateValid).withMessage('Should have a valid published start date'),
14 query('originallyPublishedEndDate').optional().custom(isDateValid).withMessage('Should have a valid published end date'),
16 query('durationMin').optional().isInt().withMessage('Should have a valid min duration'),
17 query('durationMax').optional().isInt().withMessage('Should have a valid max duration'),
19 (req: express.Request, res: express.Response, next: express.NextFunction) => {
20 logger.debug('Checking videos search query', { parameters: req.query })
22 if (areValidationErrors(req, res)) return
28 const videoChannelsSearchValidator = [
29 query('search').not().isEmpty().withMessage('Should have a valid search'),
31 (req: express.Request, res: express.Response, next: express.NextFunction) => {
32 logger.debug('Checking video channels search query', { parameters: req.query })
34 if (areValidationErrors(req, res)) return
40 // ---------------------------------------------------------------------------
43 videoChannelsSearchValidator,