2017-09-15 05:17:08 -05:00
|
|
|
import { query } from 'express-validator/check'
|
2017-06-10 15:15:25 -05:00
|
|
|
import * as express from 'express'
|
|
|
|
|
2017-05-15 15:22:03 -05:00
|
|
|
import { checkErrors } from './utils'
|
|
|
|
import { logger } from '../../helpers'
|
2016-05-13 11:10:46 -05:00
|
|
|
|
2017-09-15 05:17:08 -05:00
|
|
|
const paginationValidator = [
|
|
|
|
query('start').optional().isInt().withMessage('Should have a number start'),
|
|
|
|
query('count').optional().isInt().withMessage('Should have a number count'),
|
2016-05-13 11:10:46 -05:00
|
|
|
|
2017-09-15 05:17:08 -05:00
|
|
|
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
|
|
|
logger.debug('Checking pagination parameters', { parameters: req.query })
|
2016-05-13 11:10:46 -05:00
|
|
|
|
2017-09-15 05:17:08 -05:00
|
|
|
checkErrors(req, res, next)
|
|
|
|
}
|
|
|
|
]
|
2016-05-13 11:10:46 -05:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2017-05-15 15:22:03 -05:00
|
|
|
export {
|
|
|
|
paginationValidator
|
|
|
|
}
|