Skip to content

Commit 2e41b30

Browse files
committed
Merge pull request #988 from ParsePlatform/new-quickstart
Getting Started and Configuring Parse Server
2 parents a642fde + 6c437ff commit 2e41b30

File tree

1 file changed

+125
-62
lines changed

1 file changed

+125
-62
lines changed

README.md

Lines changed: 125 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,101 @@ Parse Server is an [open source version of the Parse backend](http://blog.parse.
88

99
Parse Server works with the Express web application framework. It can be added to existing web applications, or run by itself.
1010

11-
## Getting Started
11+
# Getting Started
12+
13+
The fastest and easiest way to get started is to run MongoDB and Parse Server locally:
14+
15+
```
16+
$ npm install -g parse-server mongodb-runner
17+
$ mongodb-runner start
18+
$ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY
19+
```
20+
21+
You can use any arbitrary string as your application id and master key. These will be used by your clients to authenticate with the Parse Server.
22+
23+
That's it! You are now running a standalone version of Parse Server on your machine.
24+
25+
**Using a remote MongoDB?** Pass the `--databaseURL DATABASE_URI` parameter when starting `parse-server`. Learn more about configuring Parse Server [here](#configuration). For a full list of available options, run `parse-server --help`.
26+
27+
### Saving your first object
28+
29+
Now that you're running Parse Server, it is time to save your first object. We'll use the [REST API](https://parse.com/docs/rest/guide), but you can easily do the same using any of the [Parse SDKs](https://parseplatform.github.io/#sdks). Run the following:
30+
31+
```bash
32+
curl -X POST \
33+
-H "X-Parse-Application-Id: APPLICATION_ID" \
34+
-H "Content-Type: application/json" \
35+
-d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
36+
http://localhost:1337/parse/classes/GameScore
37+
```
38+
39+
You should get a response similar to this:
40+
41+
```js
42+
{
43+
"objectId": "2ntvSpRGIK",
44+
"createdAt": "2016-03-11T23:51:48.050Z"
45+
}
46+
```
47+
48+
You can now retrieve this object directly (make sure to replace `2ntvSpRGIK` with the actual `objectId` you received when the object was created):
49+
50+
```bash
51+
$ curl -X GET \
52+
-H "X-Parse-Application-Id: APPLICATION_ID" \
53+
http://localhost:1337/parse/classes/GameScore/2ntvSpRGIK
54+
```
55+
```json
56+
// Response
57+
{
58+
"objectId": "2ntvSpRGIK",
59+
"score": 1337,
60+
"playerName": "Sean Plott",
61+
"cheatMode": false,
62+
"updatedAt": "2016-03-11T23:51:48.050Z",
63+
"createdAt": "2016-03-11T23:51:48.050Z"
64+
}
65+
```
66+
67+
Keeping tracks of individual object ids is not ideal, however. In most cases you will want to run a query over the collection, like so:
68+
69+
```
70+
$ curl -X GET \
71+
-H "X-Parse-Application-Id: APPLICATION_ID" \
72+
http://localhost:1337/parse/classes/GameScore
73+
```
74+
```json
75+
// The response will provide all the matching objects within the `results` array:
76+
{
77+
"results": [
78+
{
79+
"objectId": "2ntvSpRGIK",
80+
"score": 1337,
81+
"playerName": "Sean Plott",
82+
"cheatMode": false,
83+
"updatedAt": "2016-03-11T23:51:48.050Z",
84+
"createdAt": "2016-03-11T23:51:48.050Z"
85+
}
86+
]
87+
}
88+
89+
```
90+
91+
To learn more about using saving and querying objects on Parse Server, check out the [Parse documentation](https://parse.com/docs).
92+
93+
### Connect your app to Parse Server
94+
95+
Parse provides SDKs for all the major platforms. Refer to the Parse Server guide to [learn how to connect your app to Parse Server](https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide#using-parse-sdks-with-parse-server).
96+
97+
## Running Parse Server elsewhere
98+
99+
Once you have a better understanding of how the project works, please refer to the [Parse Server wiki](https://github.com/ParsePlatform/parse-server/wiki) for in-depth guides to deploy Parse Server to major infrastructure providers. Read on to learn more about additional ways of running Parse Server.
100+
101+
### Parse Server Sample Application
12102

13103
We have provided a basic [Node.js application](https://github.com/ParsePlatform/parse-server-example) that uses the Parse Server module on Express and can be easily deployed using any of the following buttons:
14104

15-
<a title="Deploy to AWS" href="https://console.aws.amazon.com/elasticbeanstalk/home?region=us-west-2#/newApplication?applicationName=ParseServer&solutionStackName=Node.js&tierName=WebServer&sourceBundleUrl=https://s3.amazonaws.com/elasticbeanstalk-samples-us-east-1/eb-parse-server-sample/parse-server-example.zip" target="_blank"><img src="http://d0.awsstatic.com/product-marketing/Elastic%20Beanstalk/deploy-to-aws.png" height="40"></a> <a title="Deploy to Heroku" href="https://heroku.com/deploy?template=https://github.com/parseplatform/parse-server-example" target="_blank"><img src="https://www.herokucdn.com/deploy/button.png"></a> <a title="Deploy to Azure" href="https://azuredeploy.net/?repository=https://github.com/parseplatform/parse-server-example" target="_blank"><img src="http://azuredeploy.net/deploybutton.png"></a>
105+
<a title="Deploy to AWS" href="https://console.aws.amazon.com/elasticbeanstalk/home?region=us-west-2#/newApplication?applicationName=ParseServer&solutionStackName=Node.js&tierName=WebServer&sourceBundleUrl=https://s3.amazonaws.com/elasticbeanstalk-samples-us-east-1/eb-parse-server-sample/parse-server-example.zip" target="_blank"><img src="http://d0.awsstatic.com/product-marketing/Elastic%20Beanstalk/deploy-to-aws.png" height="32"></a> <a title="Deploy to Heroku" href="https://heroku.com/deploy?template=https://github.com/parseplatform/parse-server-example" target="_blank"><img src="https://www.herokucdn.com/deploy/button.png"></a> <a title="Deploy to Azure" href="https://azuredeploy.net/?repository=https://github.com/parseplatform/parse-server-example" target="_blank"><img src="http://azuredeploy.net/deploybutton.png"></a>
16106

17107
### Parse Server + Express
18108

@@ -42,55 +132,26 @@ app.listen(1337, function() {
42132
});
43133
```
44134

45-
### Standalone Parse Server
46-
47-
Parse Server can also run as a standalone API server.
48-
You can configure Parse Server with a configuration file, arguments and environment variables.
49-
50-
To start the server:
51-
52-
`npm start -- --appId MYAPP --masterKey MASTER_KEY --serverURL http://localhost:1337/parse`.
53-
54-
To get more help for running the parse-server standalone, you can run:
55-
56-
`$ npm start -- --help`
57-
58-
The standalone API server supports loading a configuration file in JSON format:
59-
60-
`$ npm start -- path/to/your/config.json`
61-
62-
The default port is 1337, to use a different port set the PORT environment variable:
63-
64-
`$ PORT=8080 npm start -- path/to/your/config.json`
65-
66-
The standalone Parse Server can be configured using [environment variables](#configuration).
67-
68-
You can also install Parse Server globally:
69-
70-
`$ npm install -g parse-server`
71-
72-
Now you can just run `$ parse-server` from your command line.
73-
74-
75-
## Documentation
135+
# Documentation
76136

77137
The full documentation for Parse Server is available in the [wiki](https://github.com/ParsePlatform/parse-server/wiki). The [Parse Server guide](https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide) is a good place to get started. If you're interested in developing for Parse Server, the [Development guide](https://github.com/ParsePlatform/parse-server/wiki/Development-Guide) will help you get set up.
78138

79-
#### Migrating an Existing Parse App
139+
## Migrating an Existing Parse App
80140

81141
The hosted version of Parse will be fully retired on January 28th, 2017. If you are planning to migrate an app, you need to begin work as soon as possible. There are a few areas where Parse Server does not provide compatibility with the hosted version of Parse. Learn more in the [Migration guide](https://github.com/ParsePlatform/parse-server/wiki/Migrating-an-Existing-Parse-App).
82142

83-
### Configuration
143+
## Configuration
84144

85-
The following options can be passed to the `ParseServer` object during initialization. Alternatively, you can use the `PARSE_SERVER_OPTIONS` environment variable set to the JSON of your configuration.
145+
Parse Server can be configured using the following options. You may pass these as parameters when running a standalone `parse-server`, or by loading a configuration file in JSON format using `parse-server path/to/configuration.json`. If you're using Parse Server on Express, you may also pass these to the `ParseServer` object as options.
146+
147+
For the full list of available options, run `parse-server --help`.
86148

87149
#### Basic options
88150

89-
* `databaseURI` (required) - The connection string for your database, i.e. `mongodb://user:[email protected]/dbname`
90-
* `appId` (required) - The application id to host with this server instance
91-
* `masterKey` (required) - The master key to use for overriding ACL security
92-
* `cloud` - The absolute path to your cloud code main.js file
93-
* `fileKey` - For migrated apps, this is necessary to provide access to files already hosted on Parse.
151+
* `appId` **(required)** - The application id to host with this server instance. You can use any arbitrary string. For migrated apps, this should match your hosted Parse app.
152+
* `masterKey` **(required)** - The master key to use for overriding ACL security. You can use any arbitrary string. Keep it secret! For migrated apps, this should match your hosted Parse app.
153+
* `databaseURI` **(required)** - The connection string for your database, i.e. `mongodb://user:[email protected]/dbname`.
154+
* `cloud` - The absolute path to your cloud code `main.js` file.
94155
* `facebookAppIds` - An array of valid Facebook application IDs.
95156
* `serverURL` - URL which will be used by Cloud Code functions to make requests against.
96157
* `push` - Configuration options for APNS and GCM push. See the [wiki entry](https://github.com/ParsePlatform/parse-server/wiki/Push).
@@ -106,36 +167,38 @@ The client keys used with Parse are no longer necessary with Parse Server. If yo
106167

107168
#### Advanced options
108169

109-
* `filesAdapter` - The default behavior (GridStore) can be changed by creating an adapter class (see [`FilesAdapter.js`](https://github.com/ParsePlatform/parse-server/blob/master/src/Adapters/Files/FilesAdapter.js))
110-
* `databaseAdapter` (unfinished) - The backing store can be changed by creating an adapter class (see `DatabaseAdapter.js`)
111-
* `loggerAdapter` - The default behavior/transport (File) can be changed by creating an adapter class (see [`LoggerAdapter.js`](https://github.com/ParsePlatform/parse-server/blob/master/src/Adapters/Logger/LoggerAdapter.js))
112-
* `enableAnonymousUsers` - Defaults to true. Set to false to disable anonymous users.
113-
* `allowClientClassCreation` - Defaults to true. Set to false to disable client class creation.
170+
* `fileKey` - For migrated apps, this is necessary to provide access to files already hosted on Parse.
171+
* `filesAdapter` - The default behavior (GridStore) can be changed by creating an adapter class (see [`FilesAdapter.js`](https://github.com/ParsePlatform/parse-server/blob/master/src/Adapters/Files/FilesAdapter.js)).
172+
* `maxUploadSize` - Max file size for uploads. Defaults to 20mb.
173+
* `databaseAdapter` (unfinished) - The backing store can be changed by creating an adapter class (see `DatabaseAdapter.js`).
174+
* `loggerAdapter` - The default behavior/transport (File) can be changed by creating an adapter class (see [`LoggerAdapter.js`](https://github.com/ParsePlatform/parse-server/blob/master/src/Adapters/Logger/LoggerAdapter.js)).
175+
* `enableAnonymousUsers` - Set to false to disable anonymous users. Defaults to true.
176+
* `allowClientClassCreation` - Set to false to disable client class creation. Defaults to true.
114177
* `oauth` - Used to configure support for [3rd party authentication](https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide#oauth).
115-
* `maxUploadSize` - Defaults to 20mb. Max file size for uploads
116178

117-
#### Using environment variables
179+
```
180+
181+
### Using environment variables to configure Parse Server
118182
119-
You may also configure the Parse Server using environment variables:
183+
You may configure the Parse Server using environment variables:
120184
121-
```js
185+
```
186+
PORT
187+
PARSE_SERVER_APPLICATION_ID
188+
PARSE_SERVER_MASTER_KEY
122189
PARSE_SERVER_DATABASE_URI
190+
PARSE_SERVER_URL
123191
PARSE_SERVER_CLOUD_CODE_MAIN
124-
PARSE_SERVER_COLLECTION_PREFIX
125-
PARSE_SERVER_APPLICATION_ID // required
126-
PARSE_SERVER_MASTER_KEY // required
127-
PARSE_SERVER_CLIENT_KEY
128-
PARSE_SERVER_REST_API_KEY
129-
PARSE_SERVER_DOTNET_KEY
130-
PARSE_SERVER_JAVASCRIPT_KEY
131-
PARSE_SERVER_DOTNET_KEY
132-
PARSE_SERVER_FILE_KEY
133-
PARSE_SERVER_FACEBOOK_APP_IDS // string of comma separated list
134-
PARSE_SERVER_MAX_UPLOAD_SIZE
135-
136192
```
137193
194+
The default port is 1337, to use a different port set the PORT environment variable:
195+
196+
`$ PORT=8080 parse-server --appId=APPLICATION_ID --masterKey=MASTER_KEY`
197+
198+
For the full list of configurable environment variables, run `parse-server --help`.
199+
138200
##### Configuring File Adapters
201+
139202
Parse Server allows developers to choose from several options when hosting files: the `GridStoreAdapter`, which backed by MongoDB; the `S3Adapter`, which is backed by [Amazon S3](https://aws.amazon.com/s3/); or the `GCSAdapter`, which is backed by [Google Cloud Storage](https://cloud.google.com/storage/).
140203
141204
`GridStoreAdapter` is used by default and requires no setup, but if you're interested in using S3 or GCS, additional configuration information is available below.

0 commit comments

Comments
 (0)