feat: Prevent Parse Server start in case of unknown option in server configuration (#8987)

This commit is contained in:
Vivek Joshi
2024-04-07 18:58:15 +05:30
committed by GitHub
parent f1469c6425
commit 8758e6abb9
6 changed files with 150 additions and 4 deletions

View File

@@ -64,6 +64,7 @@ export class Config {
}
static validateOptions({
customPages,
publicServerURL,
revokeSessionOnPasswordReset,
expireInactiveSessions,
@@ -133,9 +134,18 @@ export class Config {
this.validateRateLimit(rateLimit);
this.validateLogLevels(logLevels);
this.validateDatabaseOptions(databaseOptions);
this.validateCustomPages(customPages);
this.validateAllowClientClassCreation(allowClientClassCreation);
}
static validateCustomPages(customPages) {
if (!customPages) return;
if (Object.prototype.toString.call(customPages) !== '[object Object]') {
throw Error('Parse Server option customPages must be an object.');
}
}
static validateControllers({
verifyUserEmails,
userController,
@@ -569,6 +579,7 @@ export class Config {
if (Object.prototype.toString.call(databaseOptions) !== '[object Object]') {
throw `databaseOptions must be an object`;
}
if (databaseOptions.enableSchemaHooks === undefined) {
databaseOptions.enableSchemaHooks = DatabaseOptions.enableSchemaHooks.default;
} else if (typeof databaseOptions.enableSchemaHooks !== 'boolean') {