Limit start pagination

This commit is contained in:
Chocobozzz 2021-08-02 16:16:27 +02:00
parent 0c141b121f
commit a5095a2ca8
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 7 additions and 2 deletions

View File

@ -121,6 +121,10 @@ const SORTABLE_COLUMNS = {
PLAYLISTS_SEARCH: [ 'match', 'displayName', 'createdAt' ]
}
const PAGINATION_START = {
MAX: 9000
}
const PAGINATION_COUNT = {
DEFAULT: 20,
MAX: 500
@ -178,6 +182,7 @@ export {
CONFIG,
API_VERSION,
PAGINATION_COUNT,
PAGINATION_START,
SORTABLE_COLUMNS,
INDEXER_QUEUE_CONCURRENCY,
SCHEDULER_INTERVALS_MS,

View File

@ -1,12 +1,12 @@
import * as express from 'express'
import { check } from 'express-validator'
import { PAGINATION_COUNT } from '../../initializers/constants'
import { PAGINATION_COUNT, PAGINATION_START } from '../../initializers/constants'
import { areValidationErrors } from './utils'
const paginationValidator = [
check('start')
.optional()
.isInt({ min: 0 }).withMessage('Should have a number start'),
.isInt({ min: 0, max: PAGINATION_START.MAX }).withMessage(`Should have a number start (>= 0 and < ${PAGINATION_START.MAX}`),
check('count')
.optional()