@@ -11,7 +11,7 @@ var batch = require('./batch'),
11
11
multer = require ( 'multer' ) ,
12
12
Parse = require ( 'parse/node' ) . Parse ,
13
13
httpRequest = require ( './httpRequest' ) ;
14
-
14
+
15
15
import PromiseRouter from './PromiseRouter' ;
16
16
import { GridStoreAdapter } from './Adapters/Files/GridStoreAdapter' ;
17
17
import { S3Adapter } from './Adapters/Files/S3Adapter' ;
@@ -31,12 +31,13 @@ import { SchemasRouter } from './Routers/SchemasRouter';
31
31
import { IAPValidationRouter } from './Routers/IAPValidationRouter' ;
32
32
import { PushRouter } from './Routers/PushRouter' ;
33
33
import { FilesRouter } from './Routers/FilesRouter' ;
34
- import { LogsRouter } from './Routers/LogsRouter' ;
34
+ import { LogsRouter } from './Routers/LogsRouter' ;
35
35
36
- import { loadAdapter } from './Adapters/AdapterLoader' ;
36
+ import { loadAdapter } from './Adapters/AdapterLoader' ;
37
37
import { FileLoggerAdapter } from './Adapters/Logger/FileLoggerAdapter' ;
38
38
import { LoggerController } from './Controllers/LoggerController' ;
39
39
40
+ import requiredParameter from './requiredParameter' ;
40
41
// Mutate the Parse object to add the Cloud Code handlers
41
42
addParseCloud ( ) ;
42
43
@@ -65,8 +66,8 @@ addParseCloud();
65
66
// "push": optional key from configure push
66
67
67
68
function ParseServer ( {
68
- appId,
69
- masterKey,
69
+ appId = requiredParameter ( 'You must provide an appId!' ) ,
70
+ masterKey = requiredParameter ( 'You must provide a masterKey!' ) ,
70
71
databaseAdapter,
71
72
filesAdapter,
72
73
push,
@@ -82,13 +83,9 @@ function ParseServer({
82
83
facebookAppIds = [ ] ,
83
84
enableAnonymousUsers = true ,
84
85
oauth = { } ,
85
- serverURL = '' ,
86
+ serverURL = requiredParameter ( 'You must provide a serverURL!' ) ,
86
87
maxUploadSize = '20mb'
87
88
} ) {
88
- if ( ! appId || ! masterKey ) {
89
- throw 'You must provide an appId and masterKey!' ;
90
- }
91
-
92
89
if ( databaseAdapter ) {
93
90
DatabaseAdapter . setAdapter ( databaseAdapter ) ;
94
91
}
@@ -106,8 +103,8 @@ function ParseServer({
106
103
throw "argument 'cloud' must either be a string or a function" ;
107
104
}
108
105
}
109
-
110
-
106
+
107
+
111
108
const filesControllerAdapter = loadAdapter ( filesAdapter , GridStoreAdapter ) ;
112
109
const pushControllerAdapter = loadAdapter ( push , ParsePushAdapter ) ;
113
110
const loggerControllerAdapter = loadAdapter ( loggerAdapter , FileLoggerAdapter ) ;
@@ -117,7 +114,7 @@ function ParseServer({
117
114
const filesController = new FilesController ( filesControllerAdapter ) ;
118
115
const pushController = new PushController ( pushControllerAdapter ) ;
119
116
const loggerController = new LoggerController ( loggerControllerAdapter ) ;
120
-
117
+
121
118
cache . apps [ appId ] = {
122
119
masterKey : masterKey ,
123
120
collectionPrefix : collectionPrefix ,
@@ -175,7 +172,7 @@ function ParseServer({
175
172
new LogsRouter ( ) ,
176
173
new IAPValidationRouter ( )
177
174
] ;
178
-
175
+
179
176
if ( process . env . PARSE_EXPERIMENTAL_CONFIG_ENABLED || process . env . TESTING ) {
180
177
routers . push ( require ( './global_config' ) ) ;
181
178
}
0 commit comments