Skip to content

Commit 1b59207

Browse files
authored
feat: change startup method (#923)
1 parent 4ed37e7 commit 1b59207

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

_includes/graphql/getting-started.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const parseGraphQLServer = new ParseGraphQLServer(
6868
);
6969

7070
// (Optional) Mounts the REST API
71+
await parseServer.start();
7172
app.use('/parse', parseServer.app);
7273
// Mounts the GraphQL API using graphQLPath: '/graphql'
7374
parseGraphQLServer.applyGraphQL(app);

_includes/js/users.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,8 @@ const api = new ParseServer({
512512
...
513513
});
514514
...
515-
app.use('/parse', api);
515+
await api.start();
516+
app.use('/parse', api.app);
516517
```
517518

518519
Use the `CustomAuth`:

_includes/parse-server/file-adapters.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const api = new ParseServer({
2424
enableForAuthenticatedUser: true,
2525
}
2626
});
27+
await api.start();
2728
```
2829

2930
# Configuring File Adapters
@@ -64,6 +65,7 @@ const api = new ParseServer({
6465
encryptionKey: process.env.PARSE_SERVER_ENCRYPTION_KEY, //Add your file key here. Keep it secret
6566
...
6667
});
68+
await api.start();
6769
```
6870

6971
Be sure not to lose your key or change it after encrypting files.
@@ -101,6 +103,7 @@ const api = new ParseServer({
101103
//No encryptionKey here
102104
...
103105
});
106+
await api.start();
104107

105108
//This can take awhile depending on how many files and how larger they are. It will attempt to rotate the key of all files in your filesSubDirectory
106109
//It is not recommended to do this on the production server, deploy a development server to complete the process.
@@ -421,6 +424,7 @@ const api = new ParseServer({
421424
filesAdapter: new FSFilesAdapter(), //No encryptionKey supplied
422425
...
423426
});
427+
await api.start();
424428

425429
//This can take awhile depending on how many files and how larger they are. It will attempt to rotate the key of all files in your filesSubDirectory
426430
//It is not recommended to do this on the production server, deploy a development server to complete the process.

_includes/parse-server/usage.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const api = new ParseServer({
1616
});
1717
```
1818

19-
The parameters are as follows:
19+
A few of the [Parse Server Options](https://parseplatform.org/parse-server/api/master/ParseServerOptions.html) are as follows:
2020

2121
* `databaseURI`: Connection string for your database.
2222
* `cloud`: Path to your app’s Cloud Code.
@@ -32,17 +32,20 @@ The parameters are as follows:
3232
* `auth`: Configure support for [3rd party authentication](#oauth-and-3rd-party-authentication).
3333
* `maxUploadSize`: Maximum file upload size. Make sure your server does not restrict max request body size (e.g. nginx.conf `client_max_body_size 100m;`)
3434

35-
The Parse Server object was built to be passed directly into `app.use`, which will mount the Parse API at a specified path in your Express app:
35+
Next, Parse Server can be started with the `.start` method. This ensures that the database connection is establised, cloud code is registered, and any other startup actions.
36+
37+
In order to access an express middleware for `app.use`, you can all `.app` value. This will mount the Parse API at a specified path in your Express app:
3638

3739
```js
3840
const express = require('express');
3941
const ParseServer = require('parse-server').ParseServer;
4042

4143
const app = express();
4244
const api = new ParseServer({ ... });
45+
await api.start();
4346

4447
// Serve the Parse API at /parse URL prefix
45-
app.use('/parse', api);
48+
app.use('/parse', api.app);
4649

4750
const port = 1337;
4851
app.listen(port, function() {

0 commit comments

Comments
 (0)