@@ -82,38 +82,40 @@ class ParseServer {
82
82
83
83
logging . setLogger ( loggerController ) ;
84
84
85
+ if ( cloud ) {
86
+ addParseCloud ( ) ;
87
+ if ( typeof cloud === 'function' ) {
88
+ cloud ( Parse ) ;
89
+ } else if ( typeof cloud === 'string' ) {
90
+ require ( path . resolve ( process . cwd ( ) , cloud ) ) ;
91
+ } else {
92
+ throw "argument 'cloud' must either be a string or a function" ;
93
+ }
94
+ }
95
+
85
96
// Note: Tests will start to fail if any validation happens after this is called.
86
- databaseController
87
- . performInitialization ( )
88
- . then ( ( ) => hooksController . load ( ) )
97
+ Promise . resolve ( )
98
+ . then ( async ( ) => await databaseController . performInitialization ( ) )
99
+ . then ( async ( ) => await hooksController . load ( ) )
89
100
. then ( async ( ) => {
90
101
if ( schema ) {
91
102
await new DefinedSchemas ( schema , this . config ) . execute ( ) ;
92
103
}
104
+ } )
105
+ . then ( async ( ) => {
93
106
if ( serverStartComplete ) {
94
- serverStartComplete ( ) ;
107
+ await serverStartComplete ( ) ;
95
108
}
96
109
} )
97
- . catch ( error => {
110
+ . catch ( async ( error ) => {
98
111
if ( serverStartComplete ) {
99
- serverStartComplete ( error ) ;
112
+ await serverStartComplete ( error ) ;
100
113
} else {
101
114
console . error ( error ) ;
102
115
process . exit ( 1 ) ;
103
116
}
104
117
} ) ;
105
118
106
- if ( cloud ) {
107
- addParseCloud ( ) ;
108
- if ( typeof cloud === 'function' ) {
109
- cloud ( Parse ) ;
110
- } else if ( typeof cloud === 'string' ) {
111
- require ( path . resolve ( process . cwd ( ) , cloud ) ) ;
112
- } else {
113
- throw "argument 'cloud' must either be a string or a function" ;
114
- }
115
- }
116
-
117
119
if ( security && security . enableCheck && security . enableCheckLog ) {
118
120
new CheckRunner ( options . security ) . run ( ) ;
119
121
}
0 commit comments