@@ -11,21 +11,21 @@ var batch = require('./batch'),
11
11
PromiseRouter = require ( './PromiseRouter' ) ,
12
12
httpRequest = require ( './httpRequest' ) ;
13
13
14
- import { GridStoreAdapter } from './Adapters/Files/GridStoreAdapter' ;
15
- import { S3Adapter } from './Adapters/Files/S3Adapter' ;
16
- import { FilesController } from './Controllers/FilesController' ;
14
+ import { GridStoreAdapter } from './Adapters/Files/GridStoreAdapter' ;
15
+ import { S3Adapter } from './Adapters/Files/S3Adapter' ;
16
+ import { FilesController } from './Controllers/FilesController' ;
17
17
18
- import ParsePushAdapter from './Adapters/Push/ParsePushAdapter' ;
19
- import { PushController } from './Controllers/PushController' ;
18
+ import ParsePushAdapter from './Adapters/Push/ParsePushAdapter' ;
19
+ import { PushController } from './Controllers/PushController' ;
20
20
21
- import { ClassesRouter } from './Routers/ClassesRouter' ;
21
+ import { ClassesRouter } from './Routers/ClassesRouter' ;
22
22
import { InstallationsRouter } from './Routers/InstallationsRouter' ;
23
- import { UsersRouter } from './Routers/UsersRouter' ;
24
- import { SessionsRouter } from './Routers/SessionsRouter' ;
25
- import { RolesRouter } from './Routers/RolesRouter' ;
23
+ import { UsersRouter } from './Routers/UsersRouter' ;
24
+ import { SessionsRouter } from './Routers/SessionsRouter' ;
25
+ import { RolesRouter } from './Routers/RolesRouter' ;
26
26
27
- import { FileLoggerAdapter } from './Adapters/Logger/FileLoggerAdapter' ;
28
- import { LoggerController } from './Controllers/LoggerController' ;
27
+ import { FileLoggerAdapter } from './Adapters/Logger/FileLoggerAdapter' ;
28
+ import { LoggerController } from './Controllers/LoggerController' ;
29
29
30
30
// Mutate the Parse object to add the Cloud Code handlers
31
31
addParseCloud ( ) ;
@@ -54,69 +54,81 @@ addParseCloud();
54
54
// "javascriptKey": optional key from Parse dashboard
55
55
// "push": optional key from configure push
56
56
57
- function ParseServer ( args ) {
58
- if ( ! args . appId || ! args . masterKey ) {
57
+ function ParseServer ( {
58
+ appId,
59
+ masterKey,
60
+ databaseAdapter,
61
+ filesAdapter = new GridStoreAdapter ( ) ,
62
+ push,
63
+ loggerAdapter = new FileLoggerAdapter ( ) ,
64
+ databaseURI,
65
+ cloud,
66
+ collectionPrefix = '' ,
67
+ clientKey = '' ,
68
+ javascriptKey = '' ,
69
+ dotNetKey = '' ,
70
+ restAPIKey = '' ,
71
+ fileKey = 'invalid-file-key' ,
72
+ facebookAppIds = [ ] ,
73
+ enableAnonymousUsers = true ,
74
+ oauth = { } ,
75
+ serverURL = '' ,
76
+ } ) {
77
+ if ( ! appId || ! masterKey ) {
59
78
throw 'You must provide an appId and masterKey!' ;
60
79
}
61
80
62
- if ( args . databaseAdapter ) {
63
- DatabaseAdapter . setAdapter ( args . databaseAdapter ) ;
81
+ if ( databaseAdapter ) {
82
+ DatabaseAdapter . setAdapter ( databaseAdapter ) ;
64
83
}
65
84
66
- // Make files adapter
67
- let filesAdapter = args . filesAdapter || new GridStoreAdapter ( ) ;
68
-
69
85
// Make push adapter
70
- let pushConfig = args . push ;
86
+ let pushConfig = push ;
71
87
let pushAdapter ;
72
88
if ( pushConfig && pushConfig . adapter ) {
73
89
pushAdapter = pushConfig . adapter ;
74
90
} else if ( pushConfig ) {
75
91
pushAdapter = new ParsePushAdapter ( pushConfig )
76
92
}
77
93
78
- // Make logger adapter
79
- let loggerAdapter = args . loggerAdapter || new FileLoggerAdapter ( ) ;
80
-
81
- if ( args . databaseURI ) {
82
- DatabaseAdapter . setAppDatabaseURI ( args . appId , args . databaseURI ) ;
94
+ if ( databaseURI ) {
95
+ DatabaseAdapter . setAppDatabaseURI ( appId , databaseURI ) ;
83
96
}
84
- if ( args . cloud ) {
97
+ if ( cloud ) {
85
98
addParseCloud ( ) ;
86
- if ( typeof args . cloud === 'function' ) {
87
- args . cloud ( Parse )
88
- } else if ( typeof args . cloud === 'string' ) {
89
- require ( args . cloud ) ;
99
+ if ( typeof cloud === 'function' ) {
100
+ cloud ( Parse )
101
+ } else if ( typeof cloud === 'string' ) {
102
+ require ( cloud ) ;
90
103
} else {
91
104
throw "argument 'cloud' must either be a string or a function" ;
92
105
}
93
-
94
106
}
95
107
96
108
let filesController = new FilesController ( filesAdapter ) ;
97
109
98
- cache . apps [ args . appId ] = {
99
- masterKey : args . masterKey ,
100
- collectionPrefix : args . collectionPrefix || '' ,
101
- clientKey : args . clientKey || '' ,
102
- javascriptKey : args . javascriptKey || '' ,
103
- dotNetKey : args . dotNetKey || '' ,
104
- restAPIKey : args . restAPIKey || '' ,
105
- fileKey : args . fileKey || 'invalid-file-key' ,
106
- facebookAppIds : args . facebookAppIds || [ ] ,
110
+ cache . apps [ appId ] = {
111
+ masterKey : masterKey ,
112
+ collectionPrefix : collectionPrefix ,
113
+ clientKey : clientKey ,
114
+ javascriptKey : javascriptKey ,
115
+ dotNetKey : dotNetKey ,
116
+ restAPIKey : restAPIKey ,
117
+ fileKey : fileKey ,
118
+ facebookAppIds : facebookAppIds ,
107
119
filesController : filesController ,
108
- enableAnonymousUsers : args . enableAnonymousUsers || true ,
109
- oauth : args . oauth || { } ,
120
+ enableAnonymousUsers : enableAnonymousUsers ,
121
+ oauth : oauth ,
110
122
} ;
111
123
112
124
// To maintain compatibility. TODO: Remove in v2.1
113
125
if ( process . env . FACEBOOK_APP_ID ) {
114
- cache . apps [ args . appId ] [ 'facebookAppIds' ] . push ( process . env . FACEBOOK_APP_ID ) ;
126
+ cache . apps [ appId ] [ 'facebookAppIds' ] . push ( process . env . FACEBOOK_APP_ID ) ;
115
127
}
116
128
117
129
// Initialize the node client SDK automatically
118
- Parse . initialize ( args . appId , args . javascriptKey || '' , args . masterKey ) ;
119
- Parse . serverURL = args . serverURL || '' ;
130
+ Parse . initialize ( appId , javascriptKey , masterKey ) ;
131
+ Parse . serverURL = serverURL ;
120
132
121
133
// This app serves the Parse API directly.
122
134
// It's the equivalent of https://api.parse.com/1 in the hosted Parse API.
@@ -127,7 +139,6 @@ function ParseServer(args) {
127
139
128
140
// TODO: separate this from the regular ParseServer object
129
141
if ( process . env . TESTING == 1 ) {
130
- console . log ( 'enabling integration testing-routes' ) ;
131
142
api . use ( '/' , require ( './testing-routes' ) . router ) ;
132
143
}
133
144
0 commit comments