Skip to content

Commit

Permalink
feat: deprecate PublicAPIRouter
Browse files Browse the repository at this point in the history
  • Loading branch information
dblythy committed Jan 10, 2025
1 parent a579eeb commit 40f0aa2
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
1 change: 1 addition & 0 deletions DEPRECATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The following is a list of deprecations, according to the [Deprecation Policy](h
| DEPPS8 | Login with expired 3rd party authentication token defaults to `false` | [#7079](https://github.com/parse-community/parse-server/pull/7079) | 5.3.0 (2022) | 7.0.0 (2024) | removed | - |
| DEPPS9 | Rename LiveQuery `fields` option to `keys` | [#8389](https://github.com/parse-community/parse-server/issues/8389) | 6.0.0 (2023) | 7.0.0 (2024) | removed | - |
| DEPPS10 | Config option `encodeParseObjectInCloudFunction` defaults to `true` | [#8634](https://github.com/parse-community/parse-server/issues/8634) | 6.2.0 (2023) | 8.0.0 (2025) | deprecated | - |
| DEPPS11 | Config option `pages.enableRouter` defaults to `true` | [#7625](https://github.com/parse-community/parse-server/issues/7625) | 8.0.0 (2025) | 9.0.0 (2026) | deprecated | - |

[i_deprecation]: ## "The version and date of the deprecation."
[i_removal]: ## "The version and date of the planned removal."
Expand Down
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,6 @@ const server = ParseServer({

## Custom Routes

**Caution, this is an experimental feature that may not be appropriate for production.**

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:

### Example
Expand All @@ -451,7 +449,7 @@ const api = new ParseServer({
...otherOptions,

pages: {
enableRouter: true, // Enables the experimental feature; required for custom routes
enableRouter: true,
customRoutes: [{
method: 'GET',
path: 'custom_route',
Expand Down Expand Up @@ -488,7 +486,7 @@ The following paths are already used by Parse Server's built-in features and are
| Parameter | Optional | Type | Default value | Example values | Environment variable | Description |
|------------------------------|----------|-----------------|---------------|-----------------------|------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `pages` | yes | `Object` | `undefined` | - | `PARSE_SERVER_PAGES` | The options for pages such as password reset and email verification. |
| `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.** |
| `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. |
| `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. |
| `pages.customRoutes.method` | | `String` | - | `GET`, `POST` | - | The HTTP method of the custom route. |
| `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. |
Expand Down Expand Up @@ -611,16 +609,14 @@ Assuming the script above is named, `parse_idempotency_delete_expired_records.sh
### Pages
**Caution, this is an experimental feature that may not be appropriate for production.**
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:
```js
const api = new ParseServer({
...otherOptions,
pages: {
enableRouter: true, // Enables the experimental feature; required for localization
enableRouter: true,
enableLocalization: true,
}
}
Expand Down Expand Up @@ -668,7 +664,7 @@ const api = new ParseServer({
...otherOptions,
pages: {
enableRouter: true, // Enables the experimental feature; required for localization
enableRouter: true,
enableLocalization: true,
customUrls: {
passwordReset: 'https://example.com/page.html'
Expand Down Expand Up @@ -725,7 +721,7 @@ const api = new ParseServer({
...otherOptions,

pages: {
enableRouter: true, // Enables the experimental feature; required for localization
enableRouter: true,
enableLocalization: true,
localizationJsonPath: './private/localization.json',
localizationFallbackLocale: 'en'
Expand All @@ -750,7 +746,7 @@ const api = new ParseServer({
...otherOptions,

pages: {
enableRouter: true, // Enables the experimental feature; required for localization
enableRouter: true,
placeholders: {
exampleKey: 'exampleValue'
}
Expand All @@ -764,7 +760,7 @@ const api = new ParseServer({
...otherOptions,

pages: {
enableRouter: true, // Enables the experimental feature; required for localization
enableRouter: true,
placeholders: async (params) => {
const value = await doSomething(params.locale);
return {
Expand All @@ -784,7 +780,7 @@ The following parameter and placeholder keys are reserved because they are used
| Parameter | Optional | Type | Default value | Example values | Environment variable | Description |
|-------------------------------------------------|----------|---------------------------------------|----------------------------------------|------------------------------------------------------|-----------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `pages` | yes | `Object` | `undefined` | - | `PARSE_SERVER_PAGES` | The options for pages such as password reset and email verification. |
| `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.** |
| `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. |
| `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. |
| `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. |
| `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. |
Expand Down
5 changes: 2 additions & 3 deletions src/Options/Definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,7 @@ module.exports.ParseServerOptions = {
},
pages: {
env: 'PARSE_SERVER_PAGES',
help:
'The options for pages such as password reset and email verification. Caution, this is an experimental feature that may not be appropriate for production.',
help: 'The options for pages such as password reset and email verification.',
action: parsers.objectParser,
type: 'PagesOptions',
default: {},
Expand Down Expand Up @@ -698,7 +697,7 @@ module.exports.PagesOptions = {
enableRouter: {
env: 'PARSE_SERVER_PAGES_ENABLE_ROUTER',
help:
'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.',
'Is true if the pages router should be enabled; this is required for any of the pages options to take effect.',
action: parsers.booleanParser,
default: false,
},
Expand Down
4 changes: 2 additions & 2 deletions src/Options/docs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export interface ParseServerOptions {
/* Public URL to your parse server with http:// or https://.
:ENV: PARSE_PUBLIC_SERVER_URL */
publicServerURL: ?string;
/* The options for pages such as password reset and email verification. Caution, this is an experimental feature that may not be appropriate for production.
/* The options for pages such as password reset and email verification.
:DEFAULT: {} */
pages: ?PagesOptions;
/* custom pages for password validation and reset
Expand Down Expand Up @@ -377,7 +377,7 @@ export interface SecurityOptions {
}

export interface PagesOptions {
/* 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.
/* Is true if the pages router should be enabled; this is required for any of the pages options to take effect.
:DEFAULT: false */
enableRouter: ?boolean;
/* Is true if pages should be localized; this has no effect on custom page redirects.
Expand Down
7 changes: 7 additions & 0 deletions src/Routers/PublicAPIRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ import path from 'path';
import fs from 'fs';
import qs from 'querystring';
import { Parse } from 'parse/node';
import Deprecator from '../Deprecator';

const public_html = path.resolve(__dirname, '../../public_html');
const views = path.resolve(__dirname, '../../views');

export class PublicAPIRouter extends PromiseRouter {
constructor() {

Check failure on line 14 in src/Routers/PublicAPIRouter.js

View workflow job for this annotation

GitHub Actions / Lint

Expected to call 'super()'
Deprecator.logRuntimeDeprecation({
usage: 'PublicAPIRouter',
solution: 'pages.enableRouter'
});
}
verifyEmail(req) {
const { username, token: rawToken } = req.query;
const token = rawToken && typeof rawToken !== 'string' ? rawToken.toString() : rawToken;
Expand Down

0 comments on commit 40f0aa2

Please sign in to comment.