79 lines
3.0 KiB
Markdown
79 lines
3.0 KiB
Markdown
# Parse Server 6 Migration Guide <!-- omit in toc -->
|
|
|
|
This document only highlights specific changes that require a longer explanation. For a full list of changes in Parse Server 6 please refer to the [changelog](https://github.com/parse-community/parse-server/blob/alpha/CHANGELOG.md).
|
|
|
|
---
|
|
|
|
- [Incompatible git protocol with Node 14](#incompatible-git-protocol-with-node-14)
|
|
- [Import Statement](#import-statement)
|
|
- [Asynchronous Initialization](#asynchronous-initialization)
|
|
|
|
---
|
|
|
|
## Incompatible git protocol with Node 14
|
|
|
|
Parse Server 6 uses the Node Package Manger (npm) package lock file version 2. While version 2 is supposed to be backwards compatible with version 1, you may still encounter errors due to incompatible git protocols that cannot be interpreted correctly by npm bundled with Node 14.
|
|
|
|
If you are encountering issues installing Parse Server on Node 14 because of dependency references in the package lock file using the `ssh` protocol, configure git to use the `https` protocol instead:
|
|
|
|
```
|
|
sudo git config --system url."https://github".insteadOf "ssh://git@github"
|
|
```
|
|
|
|
Alternatively you could manually replace the dependency URLs in the package lock file.
|
|
|
|
⚠️ You could also delete the package lock file and recreate it with Node 14. Keep in mind that doing so you are not using an official version of Parse Server anymore. You may be using dependencies that have not been tested as part of the Parse Server release process.
|
|
|
|
## Import Statement
|
|
|
|
The import and initialization syntax has been simplified with more intuitive naming and structure.
|
|
|
|
*Parse Server 5:*
|
|
```js
|
|
// Returns a Parse Server instance
|
|
const ParseServer = require('parse-server');
|
|
|
|
// Returns a Parse Server express middleware
|
|
const { ParseServer } = require('parse-server');
|
|
```
|
|
|
|
*Parse Server 6:*
|
|
```js
|
|
// Both return a Parse Server instance
|
|
const ParseServer = require('parse-server');
|
|
const { ParseServer } = require('parse-server');
|
|
```
|
|
|
|
To get the express middleware in Parse Server 6, configure the Parse Server instance, start Parse Server and use its `app` property. See [Asynchronous Initialization](#asynchronous-initialization) for more details.
|
|
|
|
## Asynchronous Initialization
|
|
|
|
Previously, it was possible to mount Parse Server before it was fully started up and ready to receive requests. This could result in undefined behavior, such as Parse Objects could be saved before Cloud Code was registered. To prevent this, Parse Server 6 requires to be started asynchronously before being mounted.
|
|
|
|
*Parse Server 5:*
|
|
```js
|
|
// 1. Import Parse Server
|
|
const { ParseServer } = require('parse-server');
|
|
|
|
// 2. Create a Parse Server instance as express middleware
|
|
const server = new ParseServer(config);
|
|
|
|
// 3. Mount express middleware
|
|
app.use("/parse", server);
|
|
```
|
|
|
|
*Parse Server 6:*
|
|
```js
|
|
// 1. Import Parse Server
|
|
const ParseServer = require('parse-server');
|
|
|
|
// 2. Create a Parse Server instance
|
|
const server = new ParseServer(config);
|
|
|
|
// 3. Start up Parse Server asynchronously
|
|
await server.start();
|
|
|
|
// 4. Mount express middleware
|
|
app.use("/parse", server.app);
|
|
```
|