Upgrade express validator to v4
[oweals/peertube.git] / server / middlewares / validators / pagination.ts
1 import { query } from 'express-validator/check'
2 import * as express from 'express'
3
4 import { checkErrors } from './utils'
5 import { logger } from '../../helpers'
6
7 const paginationValidator = [
8   query('start').optional().isInt().withMessage('Should have a number start'),
9   query('count').optional().isInt().withMessage('Should have a number count'),
10
11   (req: express.Request, res: express.Response, next: express.NextFunction) => {
12     logger.debug('Checking pagination parameters', { parameters: req.query })
13
14     checkErrors(req, res, next)
15   }
16 ]
17
18 // ---------------------------------------------------------------------------
19
20 export {
21   paginationValidator
22 }