PeerTube/server/middlewares/validators/pagination.ts

23 lines
663 B
TypeScript
Raw Normal View History

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