feat: add option to change the default value of the Parse.Query.limit() constraint (#8152)
This commit is contained in:
@@ -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.';
|
||||
|
||||
Reference in New Issue
Block a user