Skip to content

Commit 40812e2

Browse files
committed
Merge pull request #979 from ParsePlatform/flovilmart.SupportDashboardLikeConfig
Adds support for apps key in config file, throws if length is > 1
2 parents 0f7335b + 86f93e3 commit 40812e2

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/cli/parse-server.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ program.loadDefinitions(definitions);
99

1010
program
1111
.usage('[options] <path/to/configuration.json>');
12-
12+
1313
program.on('--help', function(){
1414
console.log(' Get Started guide:');
1515
console.log('');
@@ -31,19 +31,27 @@ program.on('--help', function(){
3131
console.log(' $ parse-server -- --appId APP_ID --masterKey MASTER_KEY --serverURL serverURL');
3232
console.log('');
3333
});
34-
34+
3535
program.parse(process.argv, process.env);
3636

3737
let options = {};
3838
if (program.args.length > 0 ) {
3939
let jsonPath = program.args[0];
4040
jsonPath = path.resolve(jsonPath);
41-
options = require(jsonPath);
41+
let jsonConfig = require(jsonPath);
42+
if (jsonConfig.apps) {
43+
if (jsonConfig.apps.length > 1) {
44+
throw 'Multiple apps are not supported';
45+
}
46+
options = jsonConfig.apps[0];
47+
} else {
48+
options = jsonConfig;
49+
}
4250
console.log(`Configuation loaded from ${jsonPath}`)
43-
}
51+
}
4452

4553
options = Object.keys(definitions).reduce(function (options, key) {
46-
if (program[key]) {
54+
if (typeof program[key] !== 'undefined') {
4755
options[key] = program[key];
4856
}
4957
return options;
@@ -66,7 +74,7 @@ const api = new ParseServer(options);
6674
app.use(options.mountPath, api);
6775

6876
var server = app.listen(options.port, function() {
69-
77+
7078
for (let key in options) {
7179
let value = options[key];
7280
if (key == "masterKey") {

0 commit comments

Comments
 (0)