diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-23 17:58:39 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 09:41:54 +0200 |
commit | f37dc0dd14d9ce0b59c454c2c1b935fcbe9727e9 (patch) | |
tree | 2050443febcdb2a3eec68b7bbf9687e26dcb24dc /server/middlewares/validators/search.ts | |
parent | 240085d0056fd97ac3c7fa8fa4ce9bc32afc4d6e (diff) | |
download | PeerTube-f37dc0dd14d9ce0b59c454c2c1b935fcbe9727e9.tar.gz PeerTube-f37dc0dd14d9ce0b59c454c2c1b935fcbe9727e9.tar.zst PeerTube-f37dc0dd14d9ce0b59c454c2c1b935fcbe9727e9.zip |
Add ability to search video channels
Diffstat (limited to 'server/middlewares/validators/search.ts')
-rw-r--r-- | server/middlewares/validators/search.ts | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/server/middlewares/validators/search.ts b/server/middlewares/validators/search.ts index e516c4c41..8baf643a5 100644 --- a/server/middlewares/validators/search.ts +++ b/server/middlewares/validators/search.ts | |||
@@ -5,7 +5,7 @@ import { query } from 'express-validator/check' | |||
5 | import { isNumberArray, isStringArray, isNSFWQueryValid } from '../../helpers/custom-validators/search' | 5 | import { isNumberArray, isStringArray, isNSFWQueryValid } from '../../helpers/custom-validators/search' |
6 | import { isBooleanValid, isDateValid, toArray } from '../../helpers/custom-validators/misc' | 6 | import { isBooleanValid, isDateValid, toArray } from '../../helpers/custom-validators/misc' |
7 | 7 | ||
8 | const searchValidator = [ | 8 | const videosSearchValidator = [ |
9 | query('search').optional().not().isEmpty().withMessage('Should have a valid search'), | 9 | query('search').optional().not().isEmpty().withMessage('Should have a valid search'), |
10 | 10 | ||
11 | query('startDate').optional().custom(isDateValid).withMessage('Should have a valid start date'), | 11 | query('startDate').optional().custom(isDateValid).withMessage('Should have a valid start date'), |
@@ -15,7 +15,19 @@ const searchValidator = [ | |||
15 | query('durationMax').optional().isInt().withMessage('Should have a valid max duration'), | 15 | query('durationMax').optional().isInt().withMessage('Should have a valid max duration'), |
16 | 16 | ||
17 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 17 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
18 | logger.debug('Checking search query', { parameters: req.query }) | 18 | logger.debug('Checking videos search query', { parameters: req.query }) |
19 | |||
20 | if (areValidationErrors(req, res)) return | ||
21 | |||
22 | return next() | ||
23 | } | ||
24 | ] | ||
25 | |||
26 | const videoChannelsSearchValidator = [ | ||
27 | query('search').not().isEmpty().withMessage('Should have a valid search'), | ||
28 | |||
29 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
30 | logger.debug('Checking video channels search query', { parameters: req.query }) | ||
19 | 31 | ||
20 | if (areValidationErrors(req, res)) return | 32 | if (areValidationErrors(req, res)) return |
21 | 33 | ||
@@ -61,5 +73,6 @@ const commonVideosFiltersValidator = [ | |||
61 | 73 | ||
62 | export { | 74 | export { |
63 | commonVideosFiltersValidator, | 75 | commonVideosFiltersValidator, |
64 | searchValidator | 76 | videoChannelsSearchValidator, |
77 | videosSearchValidator | ||
65 | } | 78 | } |