diff options
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/activitypub/pagination.ts | 9 | ||||
-rw-r--r-- | server/middlewares/validators/pagination.ts | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/server/middlewares/validators/activitypub/pagination.ts b/server/middlewares/validators/activitypub/pagination.ts index 8b32d3415..fa21f063d 100644 --- a/server/middlewares/validators/activitypub/pagination.ts +++ b/server/middlewares/validators/activitypub/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 apPaginationValidator = [ | 7 | const apPaginationValidator = [ |
7 | query('page').optional().isInt({ min: 1 }).withMessage('Should have a valid page number'), | 8 | query('page') |
8 | query('size').optional().isInt({ max: 50 }).withMessage('Should have a valid page size (max: 50)'), | 9 | .optional() |
10 | .isInt({ min: 1 }).withMessage('Should have a valid page number'), | ||
11 | query('size') | ||
12 | .optional() | ||
13 | .isInt({ min: 0, max: PAGINATION.OUTBOX.COUNT.MAX }).withMessage(`Should have a valid page size (max: ${PAGINATION.OUTBOX.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 }) |
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 }) |