Infers serverURL based on mountPath and port
This commit is contained in:
@@ -9,11 +9,6 @@ export default {
|
|||||||
help: "Your Parse Master Key",
|
help: "Your Parse Master Key",
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
"serverURL": {
|
|
||||||
env: "PARSE_SERVER_URL",
|
|
||||||
help: "URL to your parse server with http:// or https://.",
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
"port": {
|
"port": {
|
||||||
port: "PORT",
|
port: "PORT",
|
||||||
help: "The port to run the ParseServer. defaults to 1337.",
|
help: "The port to run the ParseServer. defaults to 1337.",
|
||||||
@@ -30,6 +25,10 @@ export default {
|
|||||||
env: "PARSE_SERVER_DATABASE_URI",
|
env: "PARSE_SERVER_DATABASE_URI",
|
||||||
help: "The full URI to your mongodb database"
|
help: "The full URI to your mongodb database"
|
||||||
},
|
},
|
||||||
|
"serverURL": {
|
||||||
|
env: "PARSE_SERVER_URL",
|
||||||
|
help: "URL to your parse server with http:// or https://.",
|
||||||
|
},
|
||||||
"clientKey": {
|
"clientKey": {
|
||||||
env: "PARSE_SERVER_CLIENT_KEY",
|
env: "PARSE_SERVER_CLIENT_KEY",
|
||||||
help: "Key for iOS, MacOS, tvOS clients"
|
help: "Key for iOS, MacOS, tvOS clients"
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ program.on('--help', function(){
|
|||||||
|
|
||||||
program.parse(process.argv, process.env);
|
program.parse(process.argv, process.env);
|
||||||
|
|
||||||
|
let options;
|
||||||
if (program.args.length > 0 ) {
|
if (program.args.length > 0 ) {
|
||||||
let jsonPath = program.args[0];
|
let jsonPath = program.args[0];
|
||||||
jsonPath = path.resolve(jsonPath);
|
jsonPath = path.resolve(jsonPath);
|
||||||
@@ -49,12 +50,16 @@ if (!program.appId || !program.masterKey || !program.serverURL) {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
let options = Object.keys(definitions).reduce(function (options, key) {
|
options = Object.keys(definitions).reduce(function (options, key) {
|
||||||
if (program[key]) {
|
if (program[key]) {
|
||||||
options[key] = program[key];
|
options[key] = program[key];
|
||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
}, {});
|
}, options);
|
||||||
|
|
||||||
|
if (!options.serverURL) {
|
||||||
|
options.serverURL = `http://localhost:${options.port}${options.mountPath}`;
|
||||||
|
}
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const api = new ParseServer(options);
|
const api = new ParseServer(options);
|
||||||
@@ -70,5 +75,5 @@ app.listen(options.port, function() {
|
|||||||
console.log(`${key}: ${value}`);
|
console.log(`${key}: ${value}`);
|
||||||
}
|
}
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log('parse-server running on http://localhost:'+ options.port + options.mountPath);
|
console.log('parse-server running on '+options.serverURL);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user