forked from parse-community/parse-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse-server.js
More file actions
executable file
·79 lines (68 loc) · 2.37 KB
/
parse-server.js
File metadata and controls
executable file
·79 lines (68 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import path from 'path';
import express from 'express';
import { ParseServer } from '../index';
import definitions from './cli-definitions';
import program from './utils/commander';
import colors from 'colors';
program.loadDefinitions(definitions);
program
.usage('[options] <path/to/configuration.json>');
program.on('--help', function(){
console.log(' Get Started guide:');
console.log('');
console.log(' Please have a look at the get started guide!')
console.log(' https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide');
console.log('');
console.log('');
console.log(' Usage with npm start');
console.log('');
console.log(' $ npm start -- path/to/config.json');
console.log(' $ npm start -- --appId APP_ID --masterKey MASTER_KEY --serverURL serverURL');
console.log(' $ npm start -- --appId APP_ID --masterKey MASTER_KEY --serverURL serverURL');
console.log('');
console.log('');
console.log(' Usage:');
console.log('');
console.log(' $ parse-server path/to/config.json');
console.log(' $ parse-server -- --appId APP_ID --masterKey MASTER_KEY --serverURL serverURL');
console.log(' $ parse-server -- --appId APP_ID --masterKey MASTER_KEY --serverURL serverURL');
console.log('');
});
program.parse(process.argv, process.env);
let options = {};
if (program.args.length > 0 ) {
let jsonPath = program.args[0];
jsonPath = path.resolve(jsonPath);
options = require(jsonPath);
console.log(`Configuation loaded from ${jsonPath}`)
}
if (!program.appId || !program.masterKey || !program.serverURL) {
program.outputHelp();
console.error("");
console.error(colors.red("ERROR: appId, masterKey and serverURL are required"));
console.error("");
process.exit(1);
}
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);
app.use(options.mountPath, api);
app.listen(options.port, function() {
for (let key in options) {
let value = options[key];
if (key == "masterKey") {
value = "***REDACTED***";
}
console.log(`${key}: ${value}`);
}
console.log('');
console.log('parse-server running on '+options.serverURL);
});