mirror of
https://framagit.org/framasoft/peertube/search-index/
synced 2025-01-25 13:09:26 +01:00
24 lines
724 B
TypeScript
24 lines
724 B
TypeScript
import * as express from 'express'
|
|
import { check } from 'express-validator'
|
|
import { logger } from '../../helpers/logger'
|
|
import { areValidationErrors } from './utils'
|
|
|
|
const paginationValidator = [
|
|
check('start').optional().isInt({ min: 0 }).withMessage('Should have a number start'),
|
|
check('count').optional().isInt({ min: 0 }).withMessage('Should have a number count'),
|
|
|
|
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
|
logger.debug({ parameters: req.query }, 'Checking pagination parameters')
|
|
|
|
if (areValidationErrors(req, res)) return
|
|
|
|
return next()
|
|
}
|
|
]
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
export {
|
|
paginationValidator
|
|
}
|