Check activities host
[oweals/peertube.git] / server / middlewares / validators / pagination.ts
1 import * as express from 'express'
2 import { query } from 'express-validator/check'
3 import { logger } from '../../helpers/logger'
4 import { areValidationErrors } from './utils'
5
6 const paginationValidator = [
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'),
9
10   (req: express.Request, res: express.Response, next: express.NextFunction) => {
11     logger.debug('Checking pagination parameters', { parameters: req.query })
12
13     if (areValidationErrors(req, res)) return
14
15     return next()
16   }
17 ]
18
19 // ---------------------------------------------------------------------------
20
21 export {
22   paginationValidator
23 }