]>
Commit | Line | Data |
---|---|---|
69818c93 | 1 | import * as express from 'express' |
a2431b7d | 2 | import { query } from 'express-validator/check' |
da854ddd | 3 | import { logger } from '../../helpers/logger' |
a2431b7d | 4 | import { areValidationErrors } from './utils' |
fbf1134e | 5 | |
b60e5f38 | 6 | const paginationValidator = [ |
4635f59d C |
7 | query('start').optional().isInt({ min: 0 }).withMessage('Should have a number start'), |
8 | query('count').optional().isInt({ min: 0 }).withMessage('Should have a number count'), | |
fbf1134e | 9 | |
b60e5f38 C |
10 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
11 | logger.debug('Checking pagination parameters', { parameters: req.query }) | |
fbf1134e | 12 | |
a2431b7d C |
13 | if (areValidationErrors(req, res)) return |
14 | ||
15 | return next() | |
b60e5f38 C |
16 | } |
17 | ] | |
fbf1134e C |
18 | |
19 | // --------------------------------------------------------------------------- | |
20 | ||
65fcc311 C |
21 | export { |
22 | paginationValidator | |
23 | } |