Skip to content

Commit 2130d38

Browse files
committed
Expand Getting Started section, Configuration section.
1 parent c9a398f commit 2130d38

File tree

1 file changed

+127
-62
lines changed

1 file changed

+127
-62
lines changed

README.md

Lines changed: 127 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,97 @@ 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
1212

13-
The fastest and easiest way to get started is to run MongoDB and Parse Server locally. Once you have a better understanding of how the project works, please refer to the Parse Server guide for in-depth guides to deploy Parse Server to major infrastructure providers.
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).
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
14102

15103
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:
16104

@@ -44,55 +132,24 @@ app.listen(1337, function() {
44132
});
45133
```
46134

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

79137
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.
80138

81-
#### Migrating an Existing Parse App
139+
## Migrating an Existing Parse App
82140

83141
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).
84142

85-
### Configuration
143+
## Configuration
86144

87-
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`. Alternatively, you can use the `PARSE_SERVER_OPTIONS` environment variable set to the JSON of your configuration, If you're using Parse Server on Express, you may also pass these to the `ParseServer` object as options.
88146

89147
#### Basic options
90148

91-
* `databaseURI` (required) - The connection string for your database, i.e. `mongodb://user:[email protected]/dbname`
92-
* `appId` (required) - The application id to host with this server instance
93-
* `masterKey` (required) - The master key to use for overriding ACL security
94-
* `cloud` - The absolute path to your cloud code main.js file
95-
* `fileKey` - For migrated apps, this is necessary to provide access to files already hosted on Parse.
149+
* `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.
150+
* `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.
151+
* `databaseURI` **(required)** - The connection string for your database, i.e. `mongodb://user:[email protected]/dbname`.
152+
* `cloud` - The absolute path to your cloud code `main.js` file.
96153
* `facebookAppIds` - An array of valid Facebook application IDs.
97154
* `serverURL` - URL which will be used by Cloud Code functions to make requests against.
98155
* `push` - Configuration options for APNS and GCM push. See the [wiki entry](https://github.com/ParsePlatform/parse-server/wiki/Push).
@@ -108,36 +165,44 @@ The client keys used with Parse are no longer necessary with Parse Server. If yo
108165

109166
#### Advanced options
110167

111-
* `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))
112-
* `databaseAdapter` (unfinished) - The backing store can be changed by creating an adapter class (see `DatabaseAdapter.js`)
113-
* `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))
114-
* `enableAnonymousUsers` - Defaults to true. Set to false to disable anonymous users.
115-
* `allowClientClassCreation` - Defaults to true. Set to false to disable client class creation.
168+
* `fileKey` - For migrated apps, this is necessary to provide access to files already hosted on Parse.
169+
* `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)).
170+
* `maxUploadSize` - Max file size for uploads. Defaults to 20mb.
171+
* `databaseAdapter` (unfinished) - The backing store can be changed by creating an adapter class (see `DatabaseAdapter.js`).
172+
* `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)).
173+
* `enableAnonymousUsers` - Set to false to disable anonymous users. Defaults to true.
174+
* `allowClientClassCreation` - Set to false to disable client class creation. Defaults to true.
116175
* `oauth` - Used to configure support for [3rd party authentication](https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide#oauth).
117-
* `maxUploadSize` - Defaults to 20mb. Max file size for uploads
118176

119-
#### Using environment variables
177+
### Using a JSON file to configure Parse Server
120178

121-
You may also configure the Parse Server using environment variables:
179+
The standalone API server supports loading a configuration file in JSON format:
122180

123-
```js
181+
```
182+
$ parse-server path/to/your/config.json
183+
```
184+
185+
### Using environment variables to configure Parse Server
186+
187+
You may configure the Parse Server using environment variables:
188+
189+
```
190+
PORT
191+
PARSE_SERVER_APPLICATION_ID
192+
PARSE_SERVER_MASTER_KEY
124193
PARSE_SERVER_DATABASE_URI
194+
PARSE_SERVER_URL
125195
PARSE_SERVER_CLOUD_CODE_MAIN
126-
PARSE_SERVER_COLLECTION_PREFIX
127-
PARSE_SERVER_APPLICATION_ID // required
128-
PARSE_SERVER_MASTER_KEY // required
129-
PARSE_SERVER_CLIENT_KEY
130-
PARSE_SERVER_REST_API_KEY
131-
PARSE_SERVER_DOTNET_KEY
132-
PARSE_SERVER_JAVASCRIPT_KEY
133-
PARSE_SERVER_DOTNET_KEY
134-
PARSE_SERVER_FILE_KEY
135-
PARSE_SERVER_FACEBOOK_APP_IDS // string of comma separated list
136-
PARSE_SERVER_MAX_UPLOAD_SIZE
137-
138196
```
139197

198+
The default port is 1337, to use a different port set the PORT environment variable:
199+
200+
`$ PORT=8080 parse-server --appId=APPLICATION_ID --masterKey=MASTER_KEY`
201+
202+
For the full list of configurable environment variables, run `parse-server --help`.
203+
140204
##### Configuring File Adapters
205+
141206
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/).
142207

143208
`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)