Infers serverURL based on mountPath and port

This commit is contained in:
Florent Vilmart
2016-02-24 19:16:02 -05:00
parent fe11fb54fc
commit db5338abaa
2 changed files with 12 additions and 8 deletions

View File

@@ -34,6 +34,7 @@ program.on('--help', function(){
program.parse(process.argv, process.env);
let options;
if (program.args.length > 0 ) {
let jsonPath = program.args[0];
jsonPath = path.resolve(jsonPath);
@@ -49,12 +50,16 @@ if (!program.appId || !program.masterKey || !program.serverURL) {
process.exit(1);
}
let options = Object.keys(definitions).reduce(function (options, key) {
options = Object.keys(definitions).reduce(function (options, key) {
if (program[key]) {
options[key] = program[key];
}
return options;
}, {});
}, options);
if (!options.serverURL) {
options.serverURL = `http://localhost:${options.port}${options.mountPath}`;
}
const app = express();
const api = new ParseServer(options);
@@ -70,5 +75,5 @@ app.listen(options.port, function() {
console.log(`${key}: ${value}`);
}
console.log('');
console.log('parse-server running on http://localhost:'+ options.port + options.mountPath);
console.log('parse-server running on '+options.serverURL);
});