Skip to content

Commit db5338a

Browse files
committed
Infers serverURL based on mountPath and port
1 parent fe11fb5 commit db5338a

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/cli/cli-definitions.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ export default {
99
help: "Your Parse Master Key",
1010
required: true
1111
},
12-
"serverURL": {
13-
env: "PARSE_SERVER_URL",
14-
help: "URL to your parse server with http:// or https://.",
15-
required: true
16-
},
1712
"port": {
1813
port: "PORT",
1914
help: "The port to run the ParseServer. defaults to 1337.",
@@ -30,6 +25,10 @@ export default {
3025
env: "PARSE_SERVER_DATABASE_URI",
3126
help: "The full URI to your mongodb database"
3227
},
28+
"serverURL": {
29+
env: "PARSE_SERVER_URL",
30+
help: "URL to your parse server with http:// or https://.",
31+
},
3332
"clientKey": {
3433
env: "PARSE_SERVER_CLIENT_KEY",
3534
help: "Key for iOS, MacOS, tvOS clients"

src/cli/parse-server.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ program.on('--help', function(){
3434

3535
program.parse(process.argv, process.env);
3636

37+
let options;
3738
if (program.args.length > 0 ) {
3839
let jsonPath = program.args[0];
3940
jsonPath = path.resolve(jsonPath);
@@ -49,12 +50,16 @@ if (!program.appId || !program.masterKey || !program.serverURL) {
4950
process.exit(1);
5051
}
5152

52-
let options = Object.keys(definitions).reduce(function (options, key) {
53+
options = Object.keys(definitions).reduce(function (options, key) {
5354
if (program[key]) {
5455
options[key] = program[key];
5556
}
5657
return options;
57-
}, {});
58+
}, options);
59+
60+
if (!options.serverURL) {
61+
options.serverURL = `http://localhost:${options.port}${options.mountPath}`;
62+
}
5863

5964
const app = express();
6065
const api = new ParseServer(options);
@@ -70,5 +75,5 @@ app.listen(options.port, function() {
7075
console.log(`${key}: ${value}`);
7176
}
7277
console.log('');
73-
console.log('parse-server running on http://localhost:'+ options.port + options.mountPath);
78+
console.log('parse-server running on '+options.serverURL);
7479
});

0 commit comments

Comments
 (0)