diff --git a/src/ParseServer.js b/src/ParseServer.js index e6b30d1918..9933e482fa 100644 --- a/src/ParseServer.js +++ b/src/ParseServer.js @@ -82,38 +82,40 @@ class ParseServer { logging.setLogger(loggerController); + if (cloud) { + addParseCloud(); + if (typeof cloud === 'function') { + cloud(Parse); + } else if (typeof cloud === 'string') { + require(path.resolve(process.cwd(), cloud)); + } else { + throw "argument 'cloud' must either be a string or a function"; + } + } + // Note: Tests will start to fail if any validation happens after this is called. - databaseController - .performInitialization() - .then(() => hooksController.load()) + Promise.resolve() + .then(async () => await databaseController.performInitialization()) + .then(async () => await hooksController.load()) .then(async () => { if (schema) { await new DefinedSchemas(schema, this.config).execute(); } + }) + .then(async () => { if (serverStartComplete) { - serverStartComplete(); + await serverStartComplete(); } }) - .catch(error => { + .catch(async (error) => { if (serverStartComplete) { - serverStartComplete(error); + await serverStartComplete(error); } else { console.error(error); process.exit(1); } }); - if (cloud) { - addParseCloud(); - if (typeof cloud === 'function') { - cloud(Parse); - } else if (typeof cloud === 'string') { - require(path.resolve(process.cwd(), cloud)); - } else { - throw "argument 'cloud' must either be a string or a function"; - } - } - if (security && security.enableCheck && security.enableCheckLog) { new CheckRunner(options.security).run(); }