diff options
author | Chocobozzz <me@florianbigard.com> | 2020-01-09 09:36:31 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-01-09 09:36:31 +0100 |
commit | e0b56b7495e809581a1e6447794bf7573a78af56 (patch) | |
tree | 7bf3917b7109fc8d671c994b4f501fd020257b38 /server/middlewares/validators/pagination.ts | |
parent | 240458d0c95133bfb03a3f695a1b4e5cb63e20ef (diff) | |
download | PeerTube-e0b56b7495e809581a1e6447794bf7573a78af56.tar.gz PeerTube-e0b56b7495e809581a1e6447794bf7573a78af56.tar.zst PeerTube-e0b56b7495e809581a1e6447794bf7573a78af56.zip |
Return an error on invalid count pagination
Diffstat (limited to 'server/middlewares/validators/pagination.ts')
-rw-r--r-- | server/middlewares/validators/pagination.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/server/middlewares/validators/pagination.ts b/server/middlewares/validators/pagination.ts index 80ae57c0b..1cae7848c 100644 --- a/server/middlewares/validators/pagination.ts +++ b/server/middlewares/validators/pagination.ts | |||
@@ -2,10 +2,15 @@ import * as express from 'express' | |||
2 | import { query } from 'express-validator' | 2 | import { query } from 'express-validator' |
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import { areValidationErrors } from './utils' | 4 | import { areValidationErrors } from './utils' |
5 | import { PAGINATION } from '@server/initializers/constants' | ||
5 | 6 | ||
6 | const paginationValidator = [ | 7 | const paginationValidator = [ |
7 | query('start').optional().isInt({ min: 0 }).withMessage('Should have a number start'), | 8 | query('start') |
8 | query('count').optional().isInt({ min: 0 }).withMessage('Should have a number count'), | 9 | .optional() |
10 | .isInt({ min: 0 }).withMessage('Should have a number start'), | ||
11 | query('count') | ||
12 | .optional() | ||
13 | .isInt({ min: 0, max: PAGINATION.GLOBAL.COUNT.MAX }).withMessage(`Should have a number count (max: ${PAGINATION.GLOBAL.COUNT.MAX})`), | ||
9 | 14 | ||
10 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 15 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
11 | logger.debug('Checking pagination parameters', { parameters: req.query }) | 16 | logger.debug('Checking pagination parameters', { parameters: req.query }) |