aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/search.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/search.ts')
-rw-r--r--server/middlewares/validators/search.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/server/middlewares/validators/search.ts b/server/middlewares/validators/search.ts
new file mode 100644
index 000000000..774845e8a
--- /dev/null
+++ b/server/middlewares/validators/search.ts
@@ -0,0 +1,22 @@
1import * as express from 'express'
2import { areValidationErrors } from './utils'
3import { logger } from '../../helpers/logger'
4import { query } from 'express-validator/check'
5
6const 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
20export {
21 searchValidator
22}