feat: add option to change the default value of the Parse.Query.limit() constraint (#8152)

This commit is contained in:
vzukanov
2022-09-30 01:38:57 +03:00
committed by GitHub
parent b96a4cbdc5
commit 0388956808
10 changed files with 90 additions and 27 deletions

View File

@@ -12,6 +12,7 @@ import {
PagesOptions,
SecurityOptions,
SchemaOptions,
ParseServerOptions
} from './Options/Definitions';
import { isBoolean, isString } from 'lodash';
@@ -63,6 +64,7 @@ export class Config {
revokeSessionOnPasswordReset,
expireInactiveSessions,
sessionLength,
defaultLimit,
maxLimit,
emailVerifyTokenValidityDuration,
accountLockout,
@@ -110,6 +112,7 @@ export class Config {
}
this.validateSessionConfiguration(sessionLength, expireInactiveSessions);
this.validateMasterKeyIps(masterKeyIps);
this.validateDefaultLimit(defaultLimit);
this.validateMaxLimit(maxLimit);
this.validateAllowHeaders(allowHeaders);
this.validateIdempotencyOptions(idempotencyOptions);
@@ -453,6 +456,18 @@ export class Config {
}
}
static validateDefaultLimit(defaultLimit) {
if (defaultLimit == null) {
defaultLimit = ParseServerOptions.defaultLimit.default
}
if (typeof defaultLimit !== 'number') {
throw 'Default limit must be a number.';
}
if (defaultLimit <= 0) {
throw 'Default limit must be a value greater than 0.';
}
}
static validateMaxLimit(maxLimit) {
if (maxLimit <= 0) {
throw 'Max limit must be a value greater than 0.';