]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/middlewares/validators/activitypub/pagination.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / activitypub / pagination.ts
1 import express from 'express'
2 import { query } from 'express-validator'
3 import { PAGINATION } from '@server/initializers/constants'
4 import { areValidationErrors } from '../shared'
5
6 const apPaginationValidator = [
7 query('page')
8 .optional()
9 .isInt({ min: 1 }),
10 query('size')
11 .optional()
12 .isInt({ min: 0, max: PAGINATION.OUTBOX.COUNT.MAX }).withMessage(`Should have a valid page size (max: ${PAGINATION.OUTBOX.COUNT.MAX})`),
13
14 (req: express.Request, res: express.Response, next: express.NextFunction) => {
15 if (areValidationErrors(req, res)) return
16
17 return next()
18 }
19 ]
20
21 // ---------------------------------------------------------------------------
22
23 export {
24 apPaginationValidator
25 }