Skip to content

Commit 4b1132a

Browse files
committed
Merge pull request #225 from flovilmart/standalone-server
Adds standalone parse server
2 parents ee5e06c + 098d671 commit 4b1132a

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed

README.md

+36
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,42 @@ app.listen(port, function() {
7474

7575
```
7676

77+
78+
#### Standalone usage
79+
80+
You can configure the Parse Server with environment variables:
81+
82+
```js
83+
PARSE_SERVER_DATABASE_URI
84+
PARSE_SERVER_CLOUD_CODE_MAIN
85+
PARSE_SERVER_COLLECTION_PREFIX
86+
PARSE_SERVER_APPLICATION_ID // required
87+
PARSE_SERVER_CLIENT_KEY
88+
PARSE_SERVER_REST_API_KEY
89+
PARSE_SERVER_DOTNET_KEY
90+
PARSE_SERVER_JAVASCRIPT_KEY
91+
PARSE_SERVER_DOTNET_KEY
92+
PARSE_SERVER_MASTER_KEY // required
93+
PARSE_SERVER_FILE_KEY
94+
PARSE_SERVER_FACEBOOK_APP_IDS // string of comma separated list
95+
96+
```
97+
98+
99+
100+
Alernatively, you can use the `PARSE_SERVER_OPTIONS` environment variable set to the JSON of your configuration (see Usage).
101+
102+
To start the server, just run `npm start`.
103+
104+
##### Global installation
105+
106+
You can install parse-server globally
107+
108+
`$ npm install -g parse-server`
109+
110+
Now you can just run `$ parse-server` from your command line.
111+
112+
77113
### Supported
78114

79115
* CRUD operations

bin/parse-server

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env node
2+
var express = require('express');
3+
var ParseServer = require("../index").ParseServer;
4+
5+
var app = express();
6+
7+
var options = {};
8+
if (process.env.PARSE_SERVER_OPTIONS) {
9+
10+
options = JSON.parse(process.env.PARSE_SERVER_OPTIONS);
11+
12+
} else {
13+
14+
options.databaseURI = process.env.PARSE_SERVER_DATABASE_URI;
15+
options.cloud = process.env.PARSE_SERVER_CLOUD_CODE_MAIN;
16+
options.collectionPrefix = process.env.PARSE_SERVER_COLLECTION_PREFIX;
17+
18+
// Keys and App ID
19+
options.appId = process.env.PARSE_SERVER_APPLICATION_ID;
20+
options.clientKey = process.env.PARSE_SERVER_CLIENT_KEY;
21+
options.restAPIKey = process.env.PARSE_SERVER_REST_API_KEY;
22+
options.dotNetKey = process.env.PARSE_SERVER_DOTNET_KEY;
23+
options.javascriptKey = process.env.PARSE_SERVER_JAVASCRIPT_KEY;
24+
options.dotNetKey = process.env.PARSE_SERVER_DOTNET_KEY;
25+
options.masterKey = process.env.PARSE_SERVER_MASTER_KEY;
26+
options.fileKey = process.env.PARSE_SERVER_FILE_KEY;
27+
// Comma separated list of facebook app ids
28+
var facebookAppIds = process.env.PARSE_SERVER_FACEBOOK_APP_IDS;
29+
30+
if (facebookAppIds) {
31+
facebookAppIds = facebookAppIds.split(",");
32+
options.facebookAppIds = facebookAppIds;
33+
}
34+
}
35+
36+
var mountPath = process.env.PARSE_SERVER_MOUNT_PATH || "/";
37+
var api = new ParseServer(options);
38+
app.use('/', api);
39+
40+
var port = process.env.PORT || 1337;
41+
app.listen(port, function() {
42+
console.log('parse-server-example running on http://localhost:'+ port + mountPath);
43+
});

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@
3131
"scripts": {
3232
"pretest": "MONGODB_VERSION=${MONGODB_VERSION:=3.0.8} mongodb-runner start",
3333
"test": "TESTING=1 ./node_modules/.bin/istanbul cover --include-all-sources -x **/spec/** ./node_modules/.bin/jasmine",
34-
"posttest": "mongodb-runner stop"
34+
"posttest": "mongodb-runner stop",
35+
"start": "./bin/parse-server"
3536
},
3637
"engines": {
3738
"node": ">=4.1"
39+
},
40+
"bin": {
41+
"parse-server": "./bin/parse-server"
3842
}
3943
}

0 commit comments

Comments
 (0)