]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/middlewares/validators/pagination.ts
Add ability to schedule video publication
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / pagination.ts
CommitLineData
69818c93 1import * as express from 'express'
a2431b7d 2import { query } from 'express-validator/check'
da854ddd 3import { logger } from '../../helpers/logger'
a2431b7d 4import { areValidationErrors } from './utils'
fbf1134e 5
b60e5f38 6const paginationValidator = [
4635f59d
C
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'),
fbf1134e 9
b60e5f38
C
10 (req: express.Request, res: express.Response, next: express.NextFunction) => {
11 logger.debug('Checking pagination parameters', { parameters: req.query })
fbf1134e 12
a2431b7d
C
13 if (areValidationErrors(req, res)) return
14
15 return next()
b60e5f38
C
16 }
17]
fbf1134e
C
18
19// ---------------------------------------------------------------------------
20
65fcc311
C
21export {
22 paginationValidator
23}