]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/middlewares/validators/search.ts
774845e8a38e93a55d69acf7592050d57cb2e2ff
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / search.ts
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
6 const searchValidator = [
7 query('search').not().isEmpty().withMessage('Should have a valid search'),
8
9 (req: express.Request, res: express.Response, next: express.NextFunction) => {
10 logger.debug('Checking search parameters', { parameters: req.params })
11
12 if (areValidationErrors(req, res)) return
13
14 return next()
15 }
16 ]
17
18 // ---------------------------------------------------------------------------
19
20 export {
21 searchValidator
22 }