parse-server 4.10.4 → 5.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +461 -157
- package/lib/AccountLockout.js +23 -2
- package/lib/Adapters/AdapterLoader.js +1 -1
- package/lib/Adapters/Analytics/AnalyticsAdapter.js +1 -1
- package/lib/Adapters/Auth/AuthAdapter.js +1 -1
- package/lib/Adapters/Auth/OAuth1Client.js +1 -1
- package/lib/Adapters/Auth/facebook.js +110 -10
- package/lib/Adapters/Auth/gcenter.js +1 -1
- package/lib/Adapters/Auth/gpgames.js +1 -1
- package/lib/Adapters/Auth/instagram.js +4 -2
- package/lib/Adapters/Auth/keycloak.js +1 -1
- package/lib/Adapters/Auth/ldap.js +3 -1
- package/lib/Adapters/Auth/oauth2.js +1 -1
- package/lib/Adapters/Auth/phantauth.js +1 -1
- package/lib/Adapters/Cache/CacheAdapter.js +1 -1
- package/lib/Adapters/Cache/RedisCacheAdapter.js +143 -0
- package/lib/Adapters/Cache/SchemaCache.js +31 -0
- package/lib/Adapters/Email/MailAdapter.js +1 -1
- package/lib/Adapters/Files/FilesAdapter.js +1 -1
- package/lib/Adapters/Files/GridFSBucketAdapter.js +1 -1
- package/lib/Adapters/Files/GridStoreAdapter.js +1 -1
- package/lib/Adapters/Logger/LoggerAdapter.js +1 -1
- package/lib/Adapters/Logger/WinstonLogger.js +4 -4
- package/lib/Adapters/PubSub/EventEmitterPubSub.js +5 -1
- package/lib/Adapters/PubSub/PubSubAdapter.js +1 -1
- package/lib/Adapters/Push/PushAdapter.js +1 -1
- package/lib/Adapters/Storage/Mongo/MongoCollection.js +1 -1
- package/lib/Adapters/Storage/Mongo/MongoSchemaCollection.js +21 -3
- package/lib/Adapters/Storage/Mongo/MongoStorageAdapter.js +43 -11
- package/lib/Adapters/Storage/Mongo/MongoTransform.js +9 -6
- package/lib/Adapters/Storage/Postgres/PostgresClient.js +11 -1
- package/lib/Adapters/Storage/Postgres/PostgresStorageAdapter.js +107 -62
- package/lib/Adapters/WebSocketServer/WSAdapter.js +1 -1
- package/lib/Adapters/WebSocketServer/WSSAdapter.js +1 -1
- package/lib/Auth.js +2 -39
- package/lib/Config.js +201 -8
- package/lib/Controllers/AdaptableController.js +1 -9
- package/lib/Controllers/CacheController.js +1 -1
- package/lib/Controllers/DatabaseController.js +166 -45
- package/lib/Controllers/FilesController.js +1 -1
- package/lib/Controllers/HooksController.js +2 -2
- package/lib/Controllers/LiveQueryController.js +16 -3
- package/lib/Controllers/LoggerController.js +1 -1
- package/lib/Controllers/ParseGraphQLController.js +2 -2
- package/lib/Controllers/PushController.js +1 -1
- package/lib/Controllers/SchemaController.js +114 -93
- package/lib/Controllers/UserController.js +16 -5
- package/lib/Controllers/index.js +10 -11
- package/lib/Deprecator/Deprecations.js +28 -0
- package/lib/Deprecator/Deprecator.js +135 -0
- package/lib/GraphQL/ParseGraphQLSchema.js +71 -39
- package/lib/GraphQL/ParseGraphQLServer.js +3 -3
- package/lib/GraphQL/loaders/defaultGraphQLMutations.js +2 -2
- package/lib/GraphQL/loaders/defaultGraphQLQueries.js +2 -2
- package/lib/GraphQL/loaders/defaultGraphQLTypes.js +4 -7
- package/lib/GraphQL/loaders/defaultRelaySchema.js +3 -3
- package/lib/GraphQL/loaders/filesMutations.js +2 -2
- package/lib/GraphQL/loaders/functionsMutations.js +9 -5
- package/lib/GraphQL/loaders/parseClassMutations.js +21 -9
- package/lib/GraphQL/loaders/parseClassQueries.js +9 -6
- package/lib/GraphQL/loaders/parseClassTypes.js +5 -5
- package/lib/GraphQL/loaders/schemaDirectives.js +1 -1
- package/lib/GraphQL/loaders/schemaMutations.js +8 -6
- package/lib/GraphQL/loaders/schemaQueries.js +6 -4
- package/lib/GraphQL/loaders/usersMutations.js +65 -7
- package/lib/GraphQL/transformers/constraintType.js +2 -2
- package/lib/GraphQL/transformers/inputType.js +2 -2
- package/lib/GraphQL/transformers/mutation.js +45 -10
- package/lib/GraphQL/transformers/outputType.js +2 -2
- package/lib/GraphQL/transformers/query.js +2 -2
- package/lib/GraphQL/transformers/schemaFields.js +1 -1
- package/lib/KeyPromiseQueue.js +59 -0
- package/lib/LiveQuery/Client.js +1 -1
- package/lib/LiveQuery/Id.js +1 -1
- package/lib/LiveQuery/ParseLiveQueryServer.js +144 -38
- package/lib/LiveQuery/ParseWebSocketServer.js +2 -2
- package/lib/LiveQuery/QueryTools.js +50 -1
- package/lib/LiveQuery/equalObjects.js +1 -1
- package/lib/Options/Definitions.js +256 -33
- package/lib/Options/docs.js +79 -21
- package/lib/Options/index.js +3 -1
- package/lib/Page.js +53 -0
- package/lib/ParseServer.js +40 -16
- package/lib/ParseServerRESTController.js +55 -45
- package/lib/PromiseRouter.js +7 -20
- package/lib/Push/PushQueue.js +1 -1
- package/lib/Push/PushWorker.js +2 -2
- package/lib/Push/utils.js +1 -1
- package/lib/RestQuery.js +44 -8
- package/lib/RestWrite.js +60 -10
- package/lib/Routers/AggregateRouter.js +23 -18
- package/lib/Routers/AudiencesRouter.js +2 -2
- package/lib/Routers/ClassesRouter.js +11 -11
- package/lib/Routers/CloudCodeRouter.js +1 -1
- package/lib/Routers/FeaturesRouter.js +2 -2
- package/lib/Routers/FilesRouter.js +34 -7
- package/lib/Routers/FunctionsRouter.js +2 -2
- package/lib/Routers/GlobalConfigRouter.js +2 -2
- package/lib/Routers/GraphQLRouter.js +3 -3
- package/lib/Routers/HooksRouter.js +2 -2
- package/lib/Routers/LogsRouter.js +2 -2
- package/lib/Routers/PagesRouter.js +722 -0
- package/lib/Routers/PurgeRouter.js +2 -2
- package/lib/Routers/PushRouter.js +3 -3
- package/lib/Routers/SchemasRouter.js +43 -16
- package/lib/Routers/SecurityRouter.js +47 -0
- package/lib/Routers/SessionsRouter.js +4 -2
- package/lib/Routers/UsersRouter.js +88 -17
- package/lib/SchemaMigrations/DefinedSchemas.js +421 -0
- package/lib/SchemaMigrations/Migrations.js +36 -0
- package/lib/Security/Check.js +118 -0
- package/lib/Security/CheckGroup.js +54 -0
- package/lib/Security/CheckGroups/CheckGroupDatabase.js +57 -0
- package/lib/Security/CheckGroups/CheckGroupServerConfig.js +82 -0
- package/lib/Security/CheckGroups/CheckGroups.js +24 -0
- package/lib/Security/CheckRunner.js +236 -0
- package/lib/StatusHandler.js +27 -36
- package/lib/TestUtils.js +1 -1
- package/lib/Utils.js +226 -0
- package/lib/batch.js +55 -44
- package/lib/cli/utils/commander.js +8 -3
- package/lib/cloud-code/HTTPResponse.js +1 -1
- package/lib/cloud-code/Parse.Cloud.js +155 -19
- package/lib/cloud-code/httpRequest.js +1 -1
- package/lib/index.js +10 -12
- package/lib/middlewares.js +39 -4
- package/lib/rest.js +4 -4
- package/lib/triggers.js +134 -121
- package/lib/vendor/mongodbUrl.js +8 -10
- package/package.json +60 -39
- package/CHANGELOG.md +0 -1780
- package/lib/Adapters/Cache/RedisCacheAdapter/KeyPromiseQueue.js +0 -59
- package/lib/Adapters/Cache/RedisCacheAdapter/index.js +0 -130
- package/lib/Controllers/SchemaCache.js +0 -75
package/README.md
CHANGED
|
@@ -1,77 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<h2 align="center">Our Sponsors</h2>
|
|
28
|
-
<p align="center">
|
|
29
|
-
<p align="center">Our backers and sponsors help to ensure the quality and timely development of the Parse Platform.</p>
|
|
30
|
-
<details align="center">
|
|
31
|
-
<summary align="center"><b>🥉 Bronze Sponsors</b></summary>
|
|
32
|
-
<a href="https://opencollective.com/parse-server/sponsor/0/website" target="_blank"><img src="https://opencollective.com/parse-server/sponsor/0/avatar.svg"></a>
|
|
33
|
-
</details>
|
|
34
|
-
|
|
35
|
-
</p>
|
|
36
|
-
<p align="center">
|
|
37
|
-
<a href="#backers"><img alt="Backers on Open Collective" src="https://opencollective.com/parse-server/tiers/backers/badge.svg" /></a>
|
|
38
|
-
<a href="#sponsors"><img alt="Sponsors on Open Collective" src="https://opencollective.com/parse-server/tiers/sponsors/badge.svg" /></a>
|
|
39
|
-
</p>
|
|
40
|
-
<br>
|
|
41
|
-
|
|
42
|
-
Parse Server works with the Express web application framework. It can be added to existing web applications, or run by itself.
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
[](https://github.com/parse-community/parse-server/actions?query=workflow%3Aci+branch%3Aalpha)
|
|
6
|
+
[](https://snyk.io/test/github/parse-community/parse-server)
|
|
7
|
+
[](https://codecov.io/github/parse-community/parse-server?branch=alpha)
|
|
8
|
+
[](https://github.com/parse-community/parse-dashboard/releases)
|
|
9
|
+
|
|
10
|
+
[](https://nodejs.org)
|
|
11
|
+
[](https://www.mongodb.com)
|
|
12
|
+
[](https://www.postgresql.org)
|
|
13
|
+
|
|
14
|
+
[](https://www.npmjs.com/package/parse-server)
|
|
15
|
+
[](https://www.npmjs.com/package/parse-server)
|
|
16
|
+
[](https://www.npmjs.com/package/parse-server)
|
|
17
|
+
|
|
18
|
+
[][open-collective-link]
|
|
19
|
+
[][open-collective-link]
|
|
20
|
+
[![License][license-svg]][license-link]
|
|
21
|
+
[](https://community.parseplatform.org/c/parse-server)
|
|
22
|
+
[](https://twitter.com/intent/follow?screen_name=ParsePlatform)
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
Parse Server is an open source backend that can be deployed to any infrastructure that can run Node.js. Parse Server works with the Express web application framework. It can be added to existing web applications, or run by itself.
|
|
43
27
|
|
|
44
28
|
The full documentation for Parse Server is available in the [wiki](https://github.com/parse-community/parse-server/wiki). The [Parse Server guide](http://docs.parseplatform.org/parse-server/guide/) is a good place to get started. An [API reference](http://parseplatform.org/parse-server/api/) and [Cloud Code guide](https://docs.parseplatform.org/cloudcode/guide/) are also available. If you're interested in developing for Parse Server, the [Development guide](http://docs.parseplatform.org/parse-server/guide/#development-guide) will help you get set up.
|
|
45
29
|
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
A big *thank you* 🙏 to our [sponsors](#sponsors) and [backers](#backers) who support the development of Parse Platform!
|
|
33
|
+
|
|
34
|
+
### Diamond Sponsors
|
|
35
|
+
|
|
36
|
+
[](https://opencollective.com/parse-server/contribute/diamond-sponsor-10560)
|
|
37
|
+
|
|
38
|
+
#### Bronze Sponsors
|
|
39
|
+
|
|
40
|
+
[](https://opencollective.com/parse-server/contribute/bronze-sponsor-10559)
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
46
44
|
- [Getting Started](#getting-started)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
- [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
- [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
- [
|
|
45
|
+
- [Running Parse Server](#running-parse-server)
|
|
46
|
+
- [Compatibility](#compatibility)
|
|
47
|
+
- [Node.js](#nodejs)
|
|
48
|
+
- [MongoDB](#mongodb)
|
|
49
|
+
- [PostgreSQL](#postgresql)
|
|
50
|
+
- [Locally](#locally)
|
|
51
|
+
- [Docker Container](#docker-container)
|
|
52
|
+
- [Saving an Object](#saving-an-object)
|
|
53
|
+
- [Connect an SDK](#connect-an-sdk)
|
|
54
|
+
- [Running Parse Server elsewhere](#running-parse-server-elsewhere)
|
|
55
|
+
- [Sample Application](#sample-application)
|
|
56
|
+
- [Parse Server + Express](#parse-server--express)
|
|
57
|
+
- [Configuration](#configuration)
|
|
58
|
+
- [Basic Options](#basic-options)
|
|
59
|
+
- [Client Key Options](#client-key-options)
|
|
60
|
+
- [Email Verification and Password Reset](#email-verification-and-password-reset)
|
|
61
|
+
- [Password and Account Policy](#password-and-account-policy)
|
|
62
|
+
- [Custom Routes](#custom-routes)
|
|
63
|
+
- [Example](#example)
|
|
64
|
+
- [Reserved Paths](#reserved-paths)
|
|
65
|
+
- [Parameters](#parameters)
|
|
66
|
+
- [Custom Pages](#custom-pages)
|
|
67
|
+
- [Using Environment Variables](#using-environment-variables)
|
|
68
|
+
- [Available Adapters](#available-adapters)
|
|
69
|
+
- [Configuring File Adapters](#configuring-file-adapters)
|
|
70
|
+
- [Idempotency Enforcement](#idempotency-enforcement)
|
|
71
|
+
- [Localization](#localization)
|
|
72
|
+
- [Pages](#pages)
|
|
73
|
+
- [Localization with Directory Structure](#localization-with-directory-structure)
|
|
74
|
+
- [Localization with JSON Resource](#localization-with-json-resource)
|
|
75
|
+
- [Dynamic placeholders](#dynamic-placeholders)
|
|
76
|
+
- [Reserved Keys](#reserved-keys)
|
|
77
|
+
- [Parameters](#parameters-1)
|
|
78
|
+
- [Logging](#logging)
|
|
79
|
+
- [Deprecations](#deprecations)
|
|
80
|
+
- [Live Query](#live-query)
|
|
65
81
|
- [GraphQL](#graphql)
|
|
82
|
+
- [Running](#running)
|
|
83
|
+
- [Using the CLI](#using-the-cli)
|
|
84
|
+
- [Using Docker](#using-docker)
|
|
85
|
+
- [Using Express.js](#using-expressjs)
|
|
86
|
+
- [Checking the API health](#checking-the-api-health)
|
|
87
|
+
- [Creating your first class](#creating-your-first-class)
|
|
88
|
+
- [Using automatically generated operations](#using-automatically-generated-operations)
|
|
89
|
+
- [Customizing your GraphQL Schema](#customizing-your-graphql-schema)
|
|
90
|
+
- [Learning more](#learning-more)
|
|
66
91
|
- [Upgrading to 3.0.0](#upgrading-to-300)
|
|
67
|
-
- [
|
|
68
|
-
- [Ride the Bleeding Edge](#want-to-ride-the-bleeding-edge)
|
|
92
|
+
- [Want to ride the bleeding edge?](#want-to-ride-the-bleeding-edge)
|
|
69
93
|
- [Contributing](#contributing)
|
|
70
94
|
- [Contributors](#contributors)
|
|
71
95
|
- [Sponsors](#sponsors)
|
|
72
96
|
- [Backers](#backers)
|
|
73
97
|
|
|
74
|
-
|
|
75
98
|
# Getting Started
|
|
76
99
|
|
|
77
100
|
The fastest and easiest way to get started is to run MongoDB and Parse Server locally.
|
|
@@ -84,6 +107,38 @@ Before you start make sure you have installed:
|
|
|
84
107
|
- [MongoDB](https://www.mongodb.com/) or [PostgreSQL](https://www.postgresql.org/)(with [PostGIS](https://postgis.net) 2.2.0 or higher)
|
|
85
108
|
- Optionally [Docker](https://www.docker.com/)
|
|
86
109
|
|
|
110
|
+
### Compatibility
|
|
111
|
+
|
|
112
|
+
#### Node.js
|
|
113
|
+
Parse Server is continuously tested with the most recent releases of Node.js to ensure compatibility. We follow the [Node.js Long Term Support plan](https://github.com/nodejs/Release) and only test against versions that are officially supported and have not reached their end-of-life date.
|
|
114
|
+
|
|
115
|
+
| Version | Latest Version | End-of-Life | Compatible |
|
|
116
|
+
|------------|----------------|-------------|---------------|
|
|
117
|
+
| Node.js 12 | 12.22.7 | April 2022 | ✅ Yes |
|
|
118
|
+
| Node.js 14 | 14.18.1 | April 2023 | ✅ Yes |
|
|
119
|
+
| Node.js 16 | 16.13.0 | April 2024 | ✅ Yes |
|
|
120
|
+
| Node.js 17 | 17.x | June 2022 | ❌ Not tested |
|
|
121
|
+
|
|
122
|
+
#### MongoDB
|
|
123
|
+
Parse Server is continuously tested with the most recent releases of MongoDB to ensure compatibility. We follow the [MongoDB support schedule](https://www.mongodb.com/support-policy) and only test against versions that are officially supported and have not reached their end-of-life date.
|
|
124
|
+
|
|
125
|
+
| Version | Latest Version | End-of-Life | Compatible |
|
|
126
|
+
|-------------|----------------|--------------|------------|
|
|
127
|
+
| MongoDB 4.0 | 4.0.27 | April 2022 | ✅ Yes |
|
|
128
|
+
| MongoDB 4.2 | 4.2.17 | TBD | ✅ Yes |
|
|
129
|
+
| MongoDB 4.4 | 4.4.10 | TBD | ✅ Yes |
|
|
130
|
+
| MongoDB 5.0 | 5.0.3 | January 2024 | ✅ Yes |
|
|
131
|
+
|
|
132
|
+
#### PostgreSQL
|
|
133
|
+
Parse Server is continuously tested with the most recent releases of PostgreSQL and PostGIS to ensure compatibility, using [PostGIS docker images](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&ordering=last_updated). We follow the [PostgreSQL support schedule](https://www.postgresql.org/support/versioning) and [PostGIS support schedule](https://www.postgis.net/eol_policy/) and only test against versions that are officially supported and have not reached their end-of-life date. Due to the extensive PostgreSQL support duration of 5 years, Parse Server drops support if a version is older than 3.5 years and a newer version has been available for at least 2.5 years.
|
|
134
|
+
|
|
135
|
+
| Version | PostGIS Version | End-of-Life | Parse Server Support End | Compatible |
|
|
136
|
+
|-------------|-----------------|---------------|--------------------------|------------|
|
|
137
|
+
| Postgres 11 | 3.0, 3.1 | November 2023 | April 2022 | ✅ Yes |
|
|
138
|
+
| Postgres 12 | 3.1 | November 2024 | April 2023 | ✅ Yes |
|
|
139
|
+
| Postgres 13 | 3.1 | November 2025 | April 2024 | ✅ Yes |
|
|
140
|
+
| Postgres 14 | 3.1 | November 2026 | April 2025 | ✅ Yes |
|
|
141
|
+
|
|
87
142
|
### Locally
|
|
88
143
|
```bash
|
|
89
144
|
$ npm install -g parse-server mongodb-runner
|
|
@@ -93,7 +148,7 @@ $ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongo
|
|
|
93
148
|
***Note:*** *If installation with* `-g` *fails due to permission problems* (`npm ERR! code 'EACCES'`), *please refer to [this link](https://docs.npmjs.com/getting-started/fixing-npm-permissions).*
|
|
94
149
|
|
|
95
150
|
|
|
96
|
-
###
|
|
151
|
+
### Docker Container
|
|
97
152
|
|
|
98
153
|
```bash
|
|
99
154
|
$ git clone https://github.com/parse-community/parse-server
|
|
@@ -102,13 +157,13 @@ $ docker build --tag parse-server .
|
|
|
102
157
|
$ docker run --name my-mongo -d mongo
|
|
103
158
|
```
|
|
104
159
|
|
|
105
|
-
#### Running the Parse Server Image
|
|
160
|
+
#### Running the Parse Server Image <!-- omit in toc -->
|
|
106
161
|
|
|
107
162
|
```bash
|
|
108
163
|
$ docker run --name my-parse-server -v config-vol:/parse-server/config -p 1337:1337 --link my-mongo:mongo -d parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://mongo/test
|
|
109
164
|
```
|
|
110
165
|
|
|
111
|
-
***Note:*** *If you want to use [Cloud Code](https://docs.parseplatform.org/cloudcode/guide/)
|
|
166
|
+
***Note:*** *If you want to use [Cloud Code](https://docs.parseplatform.org/cloudcode/guide/), add `-v cloud-code-vol:/parse-server/cloud --cloud /parse-server/cloud/main.js` to the command above. Make sure `main.js` is in the `cloud-code-vol` directory before starting Parse Server.*
|
|
112
167
|
|
|
113
168
|
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.
|
|
114
169
|
|
|
@@ -116,7 +171,7 @@ That's it! You are now running a standalone version of Parse Server on your mach
|
|
|
116
171
|
|
|
117
172
|
**Using a remote MongoDB?** Pass the `--databaseURI 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`.
|
|
118
173
|
|
|
119
|
-
### Saving
|
|
174
|
+
### Saving an Object
|
|
120
175
|
|
|
121
176
|
Now that you're running Parse Server, it is time to save your first object. We'll use the [REST API](http://docs.parseplatform.org/rest/guide), but you can easily do the same using any of the [Parse SDKs](http://parseplatform.org/#sdks). Run the following:
|
|
122
177
|
|
|
@@ -182,7 +237,7 @@ $ curl -X GET \
|
|
|
182
237
|
|
|
183
238
|
To learn more about using saving and querying objects on Parse Server, check out the [Parse documentation](http://docs.parseplatform.org).
|
|
184
239
|
|
|
185
|
-
### Connect
|
|
240
|
+
### Connect an SDK
|
|
186
241
|
|
|
187
242
|
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://docs.parseplatform.org/parse-server/guide/#using-parse-sdks-with-parse-server).
|
|
188
243
|
|
|
@@ -190,7 +245,7 @@ Parse provides SDKs for all the major platforms. Refer to the Parse Server guide
|
|
|
190
245
|
|
|
191
246
|
Once you have a better understanding of how the project works, please refer to the [Parse Server wiki](https://github.com/parse-community/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.
|
|
192
247
|
|
|
193
|
-
###
|
|
248
|
+
### Sample Application
|
|
194
249
|
|
|
195
250
|
We have provided a basic [Node.js application](https://github.com/parse-community/parse-server-example) that uses the Parse Server module on Express and can be easily deployed to various infrastructure providers:
|
|
196
251
|
|
|
@@ -201,7 +256,7 @@ We have provided a basic [Node.js application](https://github.com/parse-communit
|
|
|
201
256
|
* [SashiDo](https://blog.sashido.io/tag/migration/)
|
|
202
257
|
* [Digital Ocean](https://www.digitalocean.com/community/tutorials/how-to-run-parse-server-on-ubuntu-14-04)
|
|
203
258
|
* [Pivotal Web Services](https://github.com/cf-platform-eng/pws-parse-server)
|
|
204
|
-
* [Back4app](
|
|
259
|
+
* [Back4app](https://www.back4app.com/docs/get-started/welcome)
|
|
205
260
|
* [Glitch](https://glitch.com/edit/#!/parse-server)
|
|
206
261
|
* [Flynn](https://flynn.io/blog/parse-apps-on-flynn)
|
|
207
262
|
|
|
@@ -233,13 +288,13 @@ app.listen(1337, function() {
|
|
|
233
288
|
|
|
234
289
|
For a full list of available options, run `parse-server --help` or take a look at [Parse Server Configurations](http://parseplatform.org/parse-server/api/master/ParseServerOptions.html).
|
|
235
290
|
|
|
236
|
-
|
|
291
|
+
# Configuration
|
|
237
292
|
|
|
238
293
|
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.
|
|
239
294
|
|
|
240
295
|
For the full list of available options, run `parse-server --help` or take a look at [Parse Server Configurations](http://parseplatform.org/parse-server/api/master/ParseServerOptions.html).
|
|
241
296
|
|
|
242
|
-
|
|
297
|
+
## Basic Options
|
|
243
298
|
|
|
244
299
|
* `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.
|
|
245
300
|
* `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.
|
|
@@ -247,9 +302,9 @@ For the full list of available options, run `parse-server --help` or take a look
|
|
|
247
302
|
* `port` - The default port is 1337, specify this parameter to use a different port.
|
|
248
303
|
* `serverURL` - URL to your Parse Server (don't forget to specify http:// or https://). This URL will be used when making requests to Parse Server from Cloud Code.
|
|
249
304
|
* `cloud` - The absolute path to your cloud code `main.js` file.
|
|
250
|
-
* `push` - Configuration options for APNS and GCM push. See the [Push Notifications quick start](
|
|
305
|
+
* `push` - Configuration options for APNS and GCM push. See the [Push Notifications quick start](https://docs.parseplatform.org/parse-server/guide/#push-notifications-quick-start).
|
|
251
306
|
|
|
252
|
-
|
|
307
|
+
## Client Key Options
|
|
253
308
|
|
|
254
309
|
The client keys used with Parse are no longer necessary with Parse Server. If you wish to still require them, perhaps to be able to refuse access to older clients, you can set the keys at initialization time. Setting any of these keys will require all requests to provide one of the configured keys.
|
|
255
310
|
|
|
@@ -258,76 +313,34 @@ The client keys used with Parse are no longer necessary with Parse Server. If yo
|
|
|
258
313
|
* `restAPIKey`
|
|
259
314
|
* `dotNetKey`
|
|
260
315
|
|
|
261
|
-
|
|
316
|
+
## Email Verification and Password Reset
|
|
262
317
|
|
|
263
|
-
Verifying user email addresses and enabling password reset via email requires an email adapter.
|
|
318
|
+
Verifying user email addresses and enabling password reset via email requires an email adapter. There are many email adapters provided and maintained by the community. The following is an example configuration with an example email adapter. See the [Parse Server Options](https://parseplatform.org/parse-server/api/master/ParseServerOptions.html) for more details and a full list of available options.
|
|
264
319
|
|
|
265
320
|
```js
|
|
266
|
-
|
|
321
|
+
const server = ParseServer({
|
|
267
322
|
...otherOptions,
|
|
323
|
+
|
|
268
324
|
// Enable email verification
|
|
269
325
|
verifyUserEmails: true,
|
|
270
326
|
|
|
271
|
-
//
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
//
|
|
275
|
-
// email verify token expires after `emailVerifyTokenValidityDuration`
|
|
276
|
-
//
|
|
277
|
-
// `emailVerifyTokenValidityDuration` defaults to `undefined`
|
|
278
|
-
//
|
|
279
|
-
// email verify token below expires in 2 hours (= 2 * 60 * 60 == 7200 seconds)
|
|
280
|
-
emailVerifyTokenValidityDuration: 2 * 60 * 60, // in seconds (2 hours = 7200 seconds)
|
|
281
|
-
|
|
282
|
-
// set preventLoginWithUnverifiedEmail to false to allow user to login without verifying their email
|
|
283
|
-
// set preventLoginWithUnverifiedEmail to true to prevent user from login if their email is not verified
|
|
284
|
-
preventLoginWithUnverifiedEmail: false, // defaults to false
|
|
285
|
-
|
|
286
|
-
// The public URL of your app.
|
|
287
|
-
// This will appear in the link that is used to verify email addresses and reset passwords.
|
|
288
|
-
// Set the mount path as it is in serverURL
|
|
289
|
-
publicServerURL: 'https://example.com/parse',
|
|
290
|
-
// Your apps name. This will appear in the subject and body of the emails that are sent.
|
|
291
|
-
appName: 'Parse App',
|
|
292
|
-
// The email adapter
|
|
327
|
+
// Set email verification token validity to 2 hours
|
|
328
|
+
emailVerifyTokenValidityDuration: 2 * 60 * 60,
|
|
329
|
+
|
|
330
|
+
// Set email adapter
|
|
293
331
|
emailAdapter: {
|
|
294
|
-
module: '
|
|
332
|
+
module: 'example-mail-adapter',
|
|
295
333
|
options: {
|
|
296
|
-
//
|
|
297
|
-
|
|
298
|
-
// Your domain from mailgun.com
|
|
299
|
-
domain: 'example.com',
|
|
300
|
-
// Your API key from mailgun.com
|
|
301
|
-
apiKey: 'key-mykey',
|
|
334
|
+
// Additional adapter options
|
|
335
|
+
...mailAdapterOptions
|
|
302
336
|
}
|
|
303
337
|
},
|
|
304
|
-
|
|
305
|
-
// account lockout policy setting (OPTIONAL) - defaults to undefined
|
|
306
|
-
// if the account lockout policy is set and there are more than `threshold` number of failed login attempts then the `login` api call returns error code `Parse.Error.OBJECT_NOT_FOUND` with error message `Your account is locked due to multiple failed login attempts. Please try again after <duration> minute(s)`. After `duration` minutes of no login attempts, the application will allow the user to try login again.
|
|
307
|
-
accountLockout: {
|
|
308
|
-
duration: 5, // duration policy setting determines the number of minutes that a locked-out account remains locked out before automatically becoming unlocked. Set it to a value greater than 0 and less than 100000.
|
|
309
|
-
threshold: 3, // threshold policy setting determines the number of failed sign-in attempts that will cause a user account to be locked. Set it to an integer value greater than 0 and less than 1000.
|
|
310
|
-
},
|
|
311
|
-
// optional settings to enforce password policies
|
|
312
|
-
passwordPolicy: {
|
|
313
|
-
// Two optional settings to enforce strong passwords. Either one or both can be specified.
|
|
314
|
-
// If both are specified, both checks must pass to accept the password
|
|
315
|
-
// 1. a RegExp object or a regex string representing the pattern to enforce
|
|
316
|
-
validatorPattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})/, // enforce password with at least 8 char with at least 1 lower case, 1 upper case and 1 digit
|
|
317
|
-
// 2. a callback function to be invoked to validate the password
|
|
318
|
-
validatorCallback: (password) => { return validatePassword(password) },
|
|
319
|
-
validationError: 'Password must contain at least 1 digit.' // optional error message to be sent instead of the default "Password does not meet the Password Policy requirements." message.
|
|
320
|
-
doNotAllowUsername: true, // optional setting to disallow username in passwords
|
|
321
|
-
maxPasswordAge: 90, // optional setting in days for password expiry. Login fails if user does not reset the password within this period after signup/last reset.
|
|
322
|
-
maxPasswordHistory: 5, // optional setting to prevent reuse of previous n passwords. Maximum value that can be specified is 20. Not specifying it or specifying 0 will not enforce history.
|
|
323
|
-
//optional setting to set a validity duration for password reset links (in seconds)
|
|
324
|
-
resetTokenValidityDuration: 24*60*60, // expire after 24 hours
|
|
325
|
-
}
|
|
326
338
|
});
|
|
327
339
|
```
|
|
328
340
|
|
|
329
|
-
|
|
330
|
-
- [parse-
|
|
341
|
+
Email adapters contributed by the community:
|
|
342
|
+
- [parse-server-api-mail-adapter](https://www.npmjs.com/package/parse-server-api-mail-adapter) (localization, templates, universally supports any email provider)
|
|
343
|
+
- [parse-smtp-template](https://www.npmjs.com/package/parse-smtp-template) (localization, templates)
|
|
331
344
|
- [parse-server-postmark-adapter](https://www.npmjs.com/package/parse-server-postmark-adapter)
|
|
332
345
|
- [parse-server-sendgrid-adapter](https://www.npmjs.com/package/parse-server-sendgrid-adapter)
|
|
333
346
|
- [parse-server-mandrill-adapter](https://www.npmjs.com/package/parse-server-mandrill-adapter)
|
|
@@ -338,7 +351,91 @@ You can also use other email adapters contributed by the community such as:
|
|
|
338
351
|
- [simple-parse-smtp-adapter](https://www.npmjs.com/package/simple-parse-smtp-adapter)
|
|
339
352
|
- [parse-server-generic-email-adapter](https://www.npmjs.com/package/parse-server-generic-email-adapter)
|
|
340
353
|
|
|
341
|
-
|
|
354
|
+
## Password and Account Policy
|
|
355
|
+
|
|
356
|
+
Set a password and account policy that meets your security requirements. The following is an example configuration. See the [Parse Server Options](https://parseplatform.org/parse-server/api/master/ParseServerOptions.html) for more details and a full list of available options.
|
|
357
|
+
|
|
358
|
+
```js
|
|
359
|
+
const server = ParseServer({
|
|
360
|
+
...otherOptions,
|
|
361
|
+
|
|
362
|
+
// The account lock policy
|
|
363
|
+
accountLockout: {
|
|
364
|
+
// Lock the account for 5 minutes.
|
|
365
|
+
duration: 5,
|
|
366
|
+
// Lock an account after 3 failed log-in attempts
|
|
367
|
+
threshold: 3,
|
|
368
|
+
// Unlock the account after a successful password reset
|
|
369
|
+
unlockOnPasswordReset: true,
|
|
370
|
+
},
|
|
371
|
+
|
|
372
|
+
// The password policy
|
|
373
|
+
passwordPolicy: {
|
|
374
|
+
// Enforce a password of at least 8 characters which contain at least 1 lower case, 1 upper case and 1 digit
|
|
375
|
+
validatorPattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})/,
|
|
376
|
+
// Do not allow the username as part of the password
|
|
377
|
+
doNotAllowUsername: true,
|
|
378
|
+
// Do not allow to re-use the last 5 passwords when setting a new password
|
|
379
|
+
maxPasswordHistory: 5,
|
|
380
|
+
},
|
|
381
|
+
});
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## Custom Routes
|
|
385
|
+
**Caution, this is an experimental feature that may not be appropriate for production.**
|
|
386
|
+
|
|
387
|
+
Custom routes allow to build user flows with webpages, similar to the existing password reset and email verification features. Custom routes are defined with the `pages` option in the Parse Server configuration:
|
|
388
|
+
|
|
389
|
+
### Example
|
|
390
|
+
|
|
391
|
+
```js
|
|
392
|
+
const api = new ParseServer({
|
|
393
|
+
...otherOptions,
|
|
394
|
+
|
|
395
|
+
pages: {
|
|
396
|
+
enableRouter: true, // Enables the experimental feature; required for custom routes
|
|
397
|
+
customRoutes: [{
|
|
398
|
+
method: 'GET',
|
|
399
|
+
path: 'custom_route',
|
|
400
|
+
handler: async request => {
|
|
401
|
+
// custom logic
|
|
402
|
+
// ...
|
|
403
|
+
// then, depending on the outcome, return a HTML file as response
|
|
404
|
+
return { file: 'custom_page.html' };
|
|
405
|
+
}
|
|
406
|
+
}]
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
The above route can be invoked by sending a `GET` request to:
|
|
412
|
+
`https://[parseServerPublicUrl]/[parseMount]/[pagesEndpoint]/[appId]/[customRoute]`
|
|
413
|
+
|
|
414
|
+
The `handler` receives the `request` and returns a `custom_page.html` webpage from the `pages.pagesPath` directory as response. The advantage of building a custom route this way is that it automatically makes use of Parse Server's built-in capabilities, such as [page localization](#pages) and [dynamic placeholders](#dynamic-placeholders).
|
|
415
|
+
|
|
416
|
+
### Reserved Paths
|
|
417
|
+
The following paths are already used by Parse Server's built-in features and are therefore not available for custom routes. Custom routes with an identical combination of `path` and `method` are ignored.
|
|
418
|
+
|
|
419
|
+
| Path | HTTP Method | Feature |
|
|
420
|
+
|-----------------------------|-------------|--------------------|
|
|
421
|
+
| `verify_email` | `GET` | email verification |
|
|
422
|
+
| `resend_verification_email` | `POST` | email verification |
|
|
423
|
+
| `choose_password` | `GET` | password reset |
|
|
424
|
+
| `request_password_reset` | `GET` | password reset |
|
|
425
|
+
| `request_password_reset` | `POST` | password reset |
|
|
426
|
+
|
|
427
|
+
### Parameters
|
|
428
|
+
|
|
429
|
+
| Parameter | Optional | Type | Default value | Example values | Environment variable | Description |
|
|
430
|
+
|------------------------------|----------|-----------------|---------------|-----------------------|------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
431
|
+
| `pages` | yes | `Object` | `undefined` | - | `PARSE_SERVER_PAGES` | The options for pages such as password reset and email verification. |
|
|
432
|
+
| `pages.enableRouter` | yes | `Boolean` | `false` | - | `PARSE_SERVER_PAGES_ENABLE_ROUTER` | Is `true` if the pages router should be enabled; this is required for any of the pages options to take effect. **Caution, this is an experimental feature that may not be appropriate for production.** |
|
|
433
|
+
| `pages.customRoutes` | yes | `Array` | `[]` | - | `PARSE_SERVER_PAGES_CUSTOM_ROUTES` | The custom routes. The routes are added in the order they are defined here, which has to be considered since requests traverse routes in an ordered manner. Custom routes are traversed after build-in routes such as password reset and email verification. |
|
|
434
|
+
| `pages.customRoutes.method` | | `String` | - | `GET`, `POST` | - | The HTTP method of the custom route. |
|
|
435
|
+
| `pages.customRoutes.path` | | `String` | - | `custom_page` | - | The path of the custom route. Note that the same path can used if the `method` is different, for example a path `custom_page` can have two routes, a `GET` and `POST` route, which will be invoked depending on the HTTP request method. |
|
|
436
|
+
| `pages.customRoutes.handler` | | `AsyncFunction` | - | `async () => { ... }` | - | The route handler that is invoked when the route matches the HTTP request. If the handler does not return a page, the request is answered with a 404 `Not found.` response. |
|
|
437
|
+
|
|
438
|
+
## Custom Pages
|
|
342
439
|
|
|
343
440
|
It’s possible to change the default pages of the app and redirect the user to another path or domain.
|
|
344
441
|
|
|
@@ -359,7 +456,7 @@ var server = ParseServer({
|
|
|
359
456
|
})
|
|
360
457
|
```
|
|
361
458
|
|
|
362
|
-
|
|
459
|
+
## Using Environment Variables
|
|
363
460
|
|
|
364
461
|
You may configure the Parse Server using environment variables:
|
|
365
462
|
|
|
@@ -380,37 +477,38 @@ $ PORT=8080 parse-server --appId APPLICATION_ID --masterKey MASTER_KEY
|
|
|
380
477
|
|
|
381
478
|
For the full list of configurable environment variables, run `parse-server --help` or take a look at [Parse Server Configuration](https://github.com/parse-community/parse-server/blob/master/src/Options/Definitions.js).
|
|
382
479
|
|
|
383
|
-
|
|
480
|
+
## Available Adapters
|
|
384
481
|
|
|
385
|
-
All official adapters are distributed as scoped
|
|
482
|
+
All official adapters are distributed as scoped packages on [npm (@parse)](https://www.npmjs.com/search?q=scope%3Aparse).
|
|
386
483
|
|
|
387
484
|
Some well maintained adapters are also available on the [Parse Server Modules](https://github.com/parse-server-modules) organization.
|
|
388
485
|
|
|
389
486
|
You can also find more adapters maintained by the community by searching on [npm](https://www.npmjs.com/search?q=parse-server%20adapter&page=1&ranking=optimal).
|
|
390
487
|
|
|
391
|
-
|
|
488
|
+
## Configuring File Adapters
|
|
392
489
|
|
|
393
490
|
Parse Server allows developers to choose from several options when hosting files:
|
|
394
491
|
|
|
395
|
-
* `GridFSBucketAdapter
|
|
396
|
-
* `S3Adapter
|
|
397
|
-
* `GCSAdapter
|
|
492
|
+
* `GridFSBucketAdapter` - which is backed by MongoDB
|
|
493
|
+
* `S3Adapter` - which is backed by [Amazon S3](https://aws.amazon.com/s3/)
|
|
494
|
+
* `GCSAdapter` - which is backed by [Google Cloud Storage](https://cloud.google.com/storage/)
|
|
495
|
+
* `FSAdapter` - local file storage
|
|
398
496
|
|
|
399
|
-
`GridFSBucketAdapter` is used by default and requires no setup, but if you're interested in using S3
|
|
497
|
+
`GridFSBucketAdapter` is used by default and requires no setup, but if you're interested in using Amazon S3, Google Cloud Storage, or local file storage, additional configuration information is available in the [Parse Server guide](http://docs.parseplatform.org/parse-server/guide/#configuring-file-adapters).
|
|
400
498
|
|
|
401
|
-
|
|
499
|
+
## Idempotency Enforcement
|
|
402
500
|
|
|
403
501
|
**Caution, this is an experimental feature that may not be appropriate for production.**
|
|
404
502
|
|
|
405
|
-
This feature deduplicates identical requests that are received by Parse Server
|
|
503
|
+
This feature deduplicates identical requests that are received by Parse Server multiple times, typically due to network issues or network adapter access restrictions on mobile operating systems.
|
|
406
504
|
|
|
407
|
-
Identical requests are identified by their request header `X-Parse-Request-Id`. Therefore a client request has to include this header for deduplication to be applied. Requests that do not contain this header cannot be deduplicated and are processed normally by Parse Server. This means rolling out this feature to clients is seamless as Parse Server still processes
|
|
505
|
+
Identical requests are identified by their request header `X-Parse-Request-Id`. Therefore a client request has to include this header for deduplication to be applied. Requests that do not contain this header cannot be deduplicated and are processed normally by Parse Server. This means rolling out this feature to clients is seamless as Parse Server still processes requests without this header when this feature is enabled.
|
|
408
506
|
|
|
409
507
|
> This feature needs to be enabled on the client side to send the header and on the server to process the header. Refer to the specific Parse SDK docs to see whether the feature is supported yet.
|
|
410
508
|
|
|
411
509
|
Deduplication is only done for object creation and update (`POST` and `PUT` requests). Deduplication is not done for object finding and deletion (`GET` and `DELETE` requests), as these operations are already idempotent by definition.
|
|
412
510
|
|
|
413
|
-
|
|
511
|
+
### Configuration example <!-- omit in toc -->
|
|
414
512
|
```
|
|
415
513
|
let api = new ParseServer({
|
|
416
514
|
idempotencyOptions: {
|
|
@@ -419,19 +517,217 @@ let api = new ParseServer({
|
|
|
419
517
|
}
|
|
420
518
|
}
|
|
421
519
|
```
|
|
422
|
-
|
|
520
|
+
### Parameters <!-- omit in toc -->
|
|
423
521
|
|
|
424
|
-
| Parameter
|
|
425
|
-
|
|
426
|
-
| `idempotencyOptions`
|
|
427
|
-
| `idempotencyOptions.paths
|
|
428
|
-
| `idempotencyOptions.ttl`
|
|
522
|
+
| Parameter | Optional | Type | Default value | Example values | Environment variable | Description |
|
|
523
|
+
|----------------------------|----------|-----------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
524
|
+
| `idempotencyOptions` | yes | `Object` | `undefined` | | PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_OPTIONS | Setting this enables idempotency enforcement for the specified paths. |
|
|
525
|
+
| `idempotencyOptions.paths` | yes | `Array<String>` | `[]` | `.*` (all paths, includes the examples below), <br>`functions/.*` (all functions), <br>`jobs/.*` (all jobs), <br>`classes/.*` (all classes), <br>`functions/.*` (all functions), <br>`users` (user creation / update), <br>`installations` (installation creation / update) | PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_PATHS | An array of path patterns that have to match the request path for request deduplication to be enabled. The mount path must not be included, for example to match the request path `/parse/functions/myFunction` specify the path pattern `functions/myFunction`. A trailing slash of the request path is ignored, for example the path pattern `functions/myFunction` matches both `/parse/functions/myFunction` and `/parse/functions/myFunction/`. |
|
|
526
|
+
| `idempotencyOptions.ttl` | yes | `Integer` | `300` | `60` (60 seconds) | PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_TTL | The duration in seconds after which a request record is discarded from the database. Duplicate requests due to network issues can be expected to arrive within milliseconds up to several seconds. This value must be greater than `0`. |
|
|
429
527
|
|
|
430
|
-
|
|
528
|
+
### Notes <!-- omit in toc -->
|
|
431
529
|
|
|
432
530
|
- This feature is currently only available for MongoDB and not for Postgres.
|
|
433
531
|
|
|
434
|
-
|
|
532
|
+
## Localization
|
|
533
|
+
|
|
534
|
+
### Pages
|
|
535
|
+
**Caution, this is an experimental feature that may not be appropriate for production.**
|
|
536
|
+
|
|
537
|
+
Custom pages as well as feature pages (e.g. password reset, email verification) can be localized with the `pages` option in the Parse Server configuration:
|
|
538
|
+
|
|
539
|
+
```js
|
|
540
|
+
const api = new ParseServer({
|
|
541
|
+
...otherOptions,
|
|
542
|
+
|
|
543
|
+
pages: {
|
|
544
|
+
enableRouter: true, // Enables the experimental feature; required for localization
|
|
545
|
+
enableLocalization: true,
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
Localization is achieved by matching a request-supplied `locale` parameter with localized page content. The locale can be supplied in either the request query, body or header with the following keys:
|
|
551
|
+
- query: `locale`
|
|
552
|
+
- body: `locale`
|
|
553
|
+
- header: `x-parse-page-param-locale`
|
|
554
|
+
|
|
555
|
+
For example, a password reset link with the locale parameter in the query could look like this:
|
|
556
|
+
```
|
|
557
|
+
http://example.com/parse/apps/[appId]/request_password_reset?token=[token]&username=[username]&locale=de-AT
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
- Localization is only available for pages in the pages directory as set with `pages.pagesPath`.
|
|
561
|
+
- Localization for feature pages (e.g. password reset, email verification) is disabled if `pages.customUrls` are set, even if the custom URLs point to the pages within the pages path.
|
|
562
|
+
- Only `.html` files are considered for localization when localizing custom pages.
|
|
563
|
+
|
|
564
|
+
Pages can be localized in two ways:
|
|
565
|
+
|
|
566
|
+
#### Localization with Directory Structure
|
|
567
|
+
|
|
568
|
+
Pages are localized by using the corresponding file in the directory structure where the files are placed in subdirectories named after the locale or language. The file in the base directory is the default file.
|
|
569
|
+
|
|
570
|
+
**Example Directory Structure:**
|
|
571
|
+
```js
|
|
572
|
+
root/
|
|
573
|
+
├── public/ // pages base path
|
|
574
|
+
│ ├── example.html // default file
|
|
575
|
+
│ └── de/ // de language folder
|
|
576
|
+
│ │ └── example.html // de localized file
|
|
577
|
+
│ └── de-AT/ // de-AT locale folder
|
|
578
|
+
│ │ └── example.html // de-AT localized file
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
Files are matched with the locale in the following order:
|
|
582
|
+
1. Locale match, e.g. locale `de-AT` matches file in folder `de-AT`.
|
|
583
|
+
1. Language match, e.g. locale `de-CH` matches file in folder `de`.
|
|
584
|
+
1. Default; file in base folder is returned.
|
|
585
|
+
|
|
586
|
+
**Configuration Example:**
|
|
587
|
+
```js
|
|
588
|
+
const api = new ParseServer({
|
|
589
|
+
...otherOptions,
|
|
590
|
+
|
|
591
|
+
pages: {
|
|
592
|
+
enableRouter: true, // Enables the experimental feature; required for localization
|
|
593
|
+
enableLocalization: true,
|
|
594
|
+
customUrls: {
|
|
595
|
+
passwordReset: 'https://example.com/page.html'
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
Pros:
|
|
602
|
+
- All files are complete in their content and can be easily opened and previewed by viewing the file in a browser.
|
|
603
|
+
|
|
604
|
+
Cons:
|
|
605
|
+
- In most cases, a localized page differs only slightly from the default page, which could cause a lot of duplicate code that is difficult to maintain.
|
|
606
|
+
|
|
607
|
+
#### Localization with JSON Resource
|
|
608
|
+
|
|
609
|
+
Pages are localized by adding placeholders in the HTML files and providing a JSON resource that contains the translations to fill into the placeholders.
|
|
610
|
+
|
|
611
|
+
**Example Directory Structure:**
|
|
612
|
+
```js
|
|
613
|
+
root/
|
|
614
|
+
├── public/ // pages base path
|
|
615
|
+
│ ├── example.html // the page containing placeholders
|
|
616
|
+
├── private/ // folder outside of public scope
|
|
617
|
+
│ └── translations.json // JSON resource file
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
The JSON resource file loosely follows the [i18next](https://github.com/i18next/i18next) syntax, which is a syntax that is often supported by translation platforms, making it easy to manage translations, exporting them for use in Parse Server, and even to automate this workflow.
|
|
621
|
+
|
|
622
|
+
**Example JSON Content:**
|
|
623
|
+
```json
|
|
624
|
+
{
|
|
625
|
+
"en": { // resource for language `en` (English)
|
|
626
|
+
"translation": {
|
|
627
|
+
"greeting": "Hello!"
|
|
628
|
+
}
|
|
629
|
+
},
|
|
630
|
+
"de": { // resource for language `de` (German)
|
|
631
|
+
"translation": {
|
|
632
|
+
"greeting": "Hallo!"
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
"de-AT": { // resource for locale `de-AT` (Austrian German)
|
|
636
|
+
"translation": {
|
|
637
|
+
"greeting": "Servus!"
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
**Configuration Example:**
|
|
644
|
+
```js
|
|
645
|
+
const api = new ParseServer({
|
|
646
|
+
...otherOptions,
|
|
647
|
+
|
|
648
|
+
pages: {
|
|
649
|
+
enableRouter: true, // Enables the experimental feature; required for localization
|
|
650
|
+
enableLocalization: true,
|
|
651
|
+
localizationJsonPath: './private/localization.json',
|
|
652
|
+
localizationFallbackLocale: 'en'
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
Pros:
|
|
658
|
+
- There is only one HTML file to maintain that contains the placeholders that are filled with the translations according to the locale.
|
|
659
|
+
|
|
660
|
+
Cons:
|
|
661
|
+
- Files cannot be easily previewed by viewing the file in a browser because the content contains only placeholders and even HTML or CSS changes may be dynamically applied, e.g. when a localization requires a Right-To-Left layout direction.
|
|
662
|
+
- Style and other fundamental layout changes may be more difficult to apply.
|
|
663
|
+
|
|
664
|
+
#### Dynamic placeholders
|
|
665
|
+
|
|
666
|
+
In addition to feature related default parameters such as `appId` and the translations provided via JSON resource, it is possible to define custom dynamic placeholders as part of the router configuration. This works independently of localization and, also if `enableLocalization` is disabled.
|
|
667
|
+
|
|
668
|
+
**Configuration Example:**
|
|
669
|
+
```js
|
|
670
|
+
const api = new ParseServer({
|
|
671
|
+
...otherOptions,
|
|
672
|
+
|
|
673
|
+
pages: {
|
|
674
|
+
enableRouter: true, // Enables the experimental feature; required for localization
|
|
675
|
+
placeholders: {
|
|
676
|
+
exampleKey: 'exampleValue'
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
```
|
|
681
|
+
The placeholders can also be provided as function or as async function, with the `locale` and other feature related parameters passed through, to allow for dynamic placeholder values:
|
|
682
|
+
|
|
683
|
+
```js
|
|
684
|
+
const api = new ParseServer({
|
|
685
|
+
...otherOptions,
|
|
686
|
+
|
|
687
|
+
pages: {
|
|
688
|
+
enableRouter: true, // Enables the experimental feature; required for localization
|
|
689
|
+
placeholders: async (params) => {
|
|
690
|
+
const value = await doSomething(params.locale);
|
|
691
|
+
return {
|
|
692
|
+
exampleKey: value
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
#### Reserved Keys
|
|
700
|
+
|
|
701
|
+
The following parameter and placeholder keys are reserved because they are used related to features such as password reset or email verification. They should not be used as translation keys in the JSON resource or as manually defined placeholder keys in the configuration: `appId`, `appName`, `email`, `error`, `locale`, `publicServerUrl`, `token`, `username`.
|
|
702
|
+
|
|
703
|
+
#### Parameters
|
|
704
|
+
|
|
705
|
+
| Parameter | Optional | Type | Default value | Example values | Environment variable | Description |
|
|
706
|
+
|-------------------------------------------------|----------|---------------------------------------|----------------------------------------|------------------------------------------------------|-----------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
707
|
+
| `pages` | yes | `Object` | `undefined` | - | `PARSE_SERVER_PAGES` | The options for pages such as password reset and email verification. |
|
|
708
|
+
| `pages.enableRouter` | yes | `Boolean` | `false` | - | `PARSE_SERVER_PAGES_ENABLE_ROUTER` | Is `true` if the pages router should be enabled; this is required for any of the pages options to take effect. **Caution, this is an experimental feature that may not be appropriate for production.** |
|
|
709
|
+
| `pages.enableLocalization` | yes | `Boolean` | `false` | - | `PARSE_SERVER_PAGES_ENABLE_LOCALIZATION` | Is true if pages should be localized; this has no effect on custom page redirects. |
|
|
710
|
+
| `pages.localizationJsonPath` | yes | `String` | `undefined` | `./private/translations.json` | `PARSE_SERVER_PAGES_LOCALIZATION_JSON_PATH` | The path to the JSON file for localization; the translations will be used to fill template placeholders according to the locale. |
|
|
711
|
+
| `pages.localizationFallbackLocale` | yes | `String` | `en` | `en`, `en-GB`, `default` | `PARSE_SERVER_PAGES_LOCALIZATION_FALLBACK_LOCALE` | The fallback locale for localization if no matching translation is provided for the given locale. This is only relevant when providing translation resources via JSON file. |
|
|
712
|
+
| `pages.placeholders` | yes | `Object`, `Function`, `AsyncFunction` | `undefined` | `{ exampleKey: 'exampleValue' }` | `PARSE_SERVER_PAGES_PLACEHOLDERS` | The placeholder keys and values which will be filled in pages; this can be a simple object or a callback function. |
|
|
713
|
+
| `pages.forceRedirect` | yes | `Boolean` | `false` | - | `PARSE_SERVER_PAGES_FORCE_REDIRECT` | Is `true` if responses should always be redirects and never content, `false` if the response type should depend on the request type (`GET` request -> content response; `POST` request -> redirect response). |
|
|
714
|
+
| `pages.pagesPath` | yes | `String` | `./public` | `./files/pages`, `../../pages` | `PARSE_SERVER_PAGES_PAGES_PATH` | The path to the pages directory; this also defines where the static endpoint `/apps` points to. |
|
|
715
|
+
| `pages.pagesEndpoint` | yes | `String` | `apps` | - | `PARSE_SERVER_PAGES_PAGES_ENDPOINT` | The API endpoint for the pages. |
|
|
716
|
+
| `pages.customUrls` | yes | `Object` | `{}` | `{ passwordReset: 'https://example.com/page.html' }` | `PARSE_SERVER_PAGES_CUSTOM_URLS` | The URLs to the custom pages |
|
|
717
|
+
| `pages.customUrls.passwordReset` | yes | `String` | `password_reset.html` | - | `PARSE_SERVER_PAGES_CUSTOM_URL_PASSWORD_RESET` | The URL to the custom page for password reset. |
|
|
718
|
+
| `pages.customUrls.passwordResetSuccess` | yes | `String` | `password_reset_success.html` | - | `PARSE_SERVER_PAGES_CUSTOM_URL_PASSWORD_RESET_SUCCESS` | The URL to the custom page for password reset -> success. |
|
|
719
|
+
| `pages.customUrls.passwordResetLinkInvalid` | yes | `String` | `password_reset_link_invalid.html` | - | `PARSE_SERVER_PAGES_CUSTOM_URL_PASSWORD_RESET_LINK_INVALID` | The URL to the custom page for password reset -> link invalid. |
|
|
720
|
+
| `pages.customUrls.emailVerificationSuccess` | yes | `String` | `email_verification_success.html` | - | `PARSE_SERVER_PAGES_CUSTOM_URL_EMAIL_VERIFICATION_SUCCESS` | The URL to the custom page for email verification -> success. |
|
|
721
|
+
| `pages.customUrls.emailVerificationSendFail` | yes | `String` | `email_verification_send_fail.html` | - | `PARSE_SERVER_PAGES_CUSTOM_URL_EMAIL_VERIFICATION_SEND_FAIL` | The URL to the custom page for email verification -> link send fail. |
|
|
722
|
+
| `pages.customUrls.emailVerificationSendSuccess` | yes | `String` | `email_verification_send_success.html` | - | `PARSE_SERVER_PAGES_CUSTOM_URL_EMAIL_VERIFICATION_SEND_SUCCESS` | The URL to the custom page for email verification -> resend link -> success. |
|
|
723
|
+
| `pages.customUrls.emailVerificationLinkInvalid` | yes | `String` | `email_verification_link_invalid.html` | - | `PARSE_SERVER_PAGES_CUSTOM_URL_EMAIL_VERIFICATION_LINK_INVALID` | The URL to the custom page for email verification -> link invalid. |
|
|
724
|
+
| `pages.customUrls.emailVerificationLinkExpired` | yes | `String` | `email_verification_link_expired.html` | - | `PARSE_SERVER_PAGES_CUSTOM_URL_EMAIL_VERIFICATION_LINK_EXPIRED` | The URL to the custom page for email verification -> link expired. |
|
|
725
|
+
|
|
726
|
+
### Notes <!-- omit in toc -->
|
|
727
|
+
|
|
728
|
+
- In combination with the [Parse Server API Mail Adapter](https://www.npmjs.com/package/parse-server-api-mail-adapter) Parse Server provides a fully localized flow (emails -> pages) for the user. The email adapter sends a localized email and adds a locale parameter to the password reset or email verification link, which is then used to respond with localized pages.
|
|
729
|
+
|
|
730
|
+
## Logging
|
|
435
731
|
|
|
436
732
|
Parse Server will, by default, log:
|
|
437
733
|
* to the console
|
|
@@ -441,13 +737,17 @@ Logs are also viewable in Parse Dashboard.
|
|
|
441
737
|
|
|
442
738
|
**Want to log each request and response?** Set the `VERBOSE` environment variable when starting `parse-server`. Usage :- `VERBOSE='1' parse-server --appId APPLICATION_ID --masterKey MASTER_KEY`
|
|
443
739
|
|
|
444
|
-
**Want logs to be
|
|
740
|
+
**Want logs to be placed in a different folder?** Pass the `PARSE_SERVER_LOGS_FOLDER` environment variable when starting `parse-server`. Usage :- `PARSE_SERVER_LOGS_FOLDER='<path-to-logs-folder>' parse-server --appId APPLICATION_ID --masterKey MASTER_KEY`
|
|
445
741
|
|
|
446
742
|
**Want to log specific levels?** Pass the `logLevel` parameter when starting `parse-server`. Usage :- `parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --logLevel LOG_LEVEL`
|
|
447
743
|
|
|
448
744
|
**Want new line delimited JSON error logs (for consumption by CloudWatch, Google Cloud Logging, etc)?** Pass the `JSON_LOGS` environment variable when starting `parse-server`. Usage :- `JSON_LOGS='1' parse-server --appId APPLICATION_ID --masterKey MASTER_KEY`
|
|
449
745
|
|
|
450
|
-
#
|
|
746
|
+
# Deprecations
|
|
747
|
+
|
|
748
|
+
See the [Deprecation Plan](https://github.com/parse-community/parse-server/blob/master/DEPRECATIONS.md) for an overview of deprecations and planned breaking changes.
|
|
749
|
+
|
|
750
|
+
# Live Query
|
|
451
751
|
|
|
452
752
|
Live queries are meant to be used in real-time reactive applications, where just using the traditional query paradigm could cause several problems, like increased response time and high network and server usage. Live queries should be used in cases where you need to continuously update a page with fresh data coming from the database, which often happens in (but is not limited to) online games, messaging clients and shared to-do lists.
|
|
453
753
|
|
|
@@ -484,13 +784,13 @@ $ docker build --tag parse-server .
|
|
|
484
784
|
$ docker run --name my-mongo -d mongo
|
|
485
785
|
```
|
|
486
786
|
|
|
487
|
-
#### Running the Parse Server Image
|
|
787
|
+
#### Running the Parse Server Image <!-- omit in toc -->
|
|
488
788
|
|
|
489
789
|
```bash
|
|
490
790
|
$ docker run --name my-parse-server --link my-mongo:mongo -v config-vol:/parse-server/config -p 1337:1337 -d parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://mongo/test --publicServerURL http://localhost:1337/parse --mountGraphQL --mountPlayground
|
|
491
791
|
```
|
|
492
792
|
|
|
493
|
-
***Note:*** *If you want to use [Cloud Code](https://docs.parseplatform.org/cloudcode/guide/)
|
|
793
|
+
***Note:*** *If you want to use [Cloud Code](https://docs.parseplatform.org/cloudcode/guide/), add `-v cloud-code-vol:/parse-server/cloud --cloud /parse-server/cloud/main.js` to the command above. Make sure `main.js` is in the `cloud-code-vol` directory before starting Parse Server.*
|
|
494
794
|
|
|
495
795
|
After starting the server, you can visit http://localhost:1337/playground in your browser to start playing with your GraphQL API.
|
|
496
796
|
|
|
@@ -731,7 +1031,7 @@ To start creating your custom schema, you need to code a `schema.graphql` file a
|
|
|
731
1031
|
$ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://localhost/test --publicServerURL http://localhost:1337/parse --cloud ./cloud/main.js --graphQLSchema ./cloud/schema.graphql --mountGraphQL --mountPlayground
|
|
732
1032
|
```
|
|
733
1033
|
|
|
734
|
-
### Creating your first custom query
|
|
1034
|
+
### Creating your first custom query <!-- omit in toc -->
|
|
735
1035
|
|
|
736
1036
|
Use the code below for your `schema.graphql` and `main.js` files. Then restart your Parse Server.
|
|
737
1037
|
|
|
@@ -793,7 +1093,7 @@ directly on this branch:
|
|
|
793
1093
|
npm install parse-community/parse-server.git#master
|
|
794
1094
|
```
|
|
795
1095
|
|
|
796
|
-
## Experimenting
|
|
1096
|
+
## Experimenting <!-- omit in toc -->
|
|
797
1097
|
|
|
798
1098
|
You can also use your own forks, and work in progress branches by specifying them:
|
|
799
1099
|
|
|
@@ -857,3 +1157,7 @@ Support us with a monthly donation and help us continue our activities. [Become
|
|
|
857
1157
|
-----
|
|
858
1158
|
|
|
859
1159
|
As of April 5, 2017, Parse, LLC has transferred this code to the parse-community organization, and will no longer be contributing to or distributing this code.
|
|
1160
|
+
|
|
1161
|
+
[license-svg]: https://img.shields.io/badge/license-BSD-lightgrey.svg
|
|
1162
|
+
[license-link]: LICENSE
|
|
1163
|
+
[open-collective-link]: https://opencollective.com/parse-server
|