1
0
Fork 0
peertube/server/middlewares/validators/activitypub/pagination.ts

24 lines
749 B
TypeScript
Raw Normal View History

2020-01-08 23:43:52 +00:00
import * as express from 'express'
import { query } from 'express-validator'
import { logger } from '../../../helpers/logger'
import { areValidationErrors } from '../utils'
const apPaginationValidator = [
query('page').optional().isInt({ min: 1 }).withMessage('Should have a valid page number'),
query('size').optional().isInt({ max: 50 }).withMessage('Should have a valid page size (max: 50)'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking pagination parameters', { parameters: req.query })
if (areValidationErrors(req, res)) return
return next()
}
]
// ---------------------------------------------------------------------------
export {
apPaginationValidator
}