Skip to content

Commit 7f66629

Browse files
authored
feat: Deprecate PublicAPIRouter in favor of PagesRouter (#9526)
1 parent 85b71da commit 7f66629

File tree

6 files changed

+23
-19
lines changed

6 files changed

+23
-19
lines changed

DEPRECATIONS.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The following is a list of deprecations, according to the [Deprecation Policy](h
1414
| 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 | - |
1515
| 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 | - |
1616
| 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 | - |
17+
| DEPPS11 | Replace `PublicAPIRouter` with `PagesRouter` | [#7625](https://github.com/parse-community/parse-server/issues/7625) | 8.0.0 (2025) | 9.0.0 (2026) | deprecated | - |
1718

1819
[i_deprecation]: ## "The version and date of the deprecation."
1920
[i_removal]: ## "The version and date of the planned removal."

README.md

+8-12
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,6 @@ const server = ParseServer({
437437

438438
## Custom Routes
439439

440-
**Caution, this is an experimental feature that may not be appropriate for production.**
441-
442440
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:
443441

444442
### Example
@@ -448,7 +446,7 @@ const api = new ParseServer({
448446
...otherOptions,
449447

450448
pages: {
451-
enableRouter: true, // Enables the experimental feature; required for custom routes
449+
enableRouter: true,
452450
customRoutes: [{
453451
method: 'GET',
454452
path: 'custom_route',
@@ -485,7 +483,7 @@ The following paths are already used by Parse Server's built-in features and are
485483
| Parameter | Optional | Type | Default value | Example values | Environment variable | Description |
486484
|------------------------------|----------|-----------------|---------------|-----------------------|------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
487485
| `pages` | yes | `Object` | `undefined` | - | `PARSE_SERVER_PAGES` | The options for pages such as password reset and email verification. |
488-
| `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.** |
486+
| `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. |
489487
| `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. |
490488
| `pages.customRoutes.method` | | `String` | - | `GET`, `POST` | - | The HTTP method of the custom route. |
491489
| `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. |
@@ -608,16 +606,14 @@ Assuming the script above is named, `parse_idempotency_delete_expired_records.sh
608606
609607
### Pages
610608
611-
**Caution, this is an experimental feature that may not be appropriate for production.**
612-
613609
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:
614610
615611
```js
616612
const api = new ParseServer({
617613
...otherOptions,
618614
619615
pages: {
620-
enableRouter: true, // Enables the experimental feature; required for localization
616+
enableRouter: true,
621617
enableLocalization: true,
622618
}
623619
}
@@ -665,7 +661,7 @@ const api = new ParseServer({
665661
...otherOptions,
666662
667663
pages: {
668-
enableRouter: true, // Enables the experimental feature; required for localization
664+
enableRouter: true,
669665
enableLocalization: true,
670666
customUrls: {
671667
passwordReset: 'https://example.com/page.html'
@@ -722,7 +718,7 @@ const api = new ParseServer({
722718
...otherOptions,
723719

724720
pages: {
725-
enableRouter: true, // Enables the experimental feature; required for localization
721+
enableRouter: true,
726722
enableLocalization: true,
727723
localizationJsonPath: './private/localization.json',
728724
localizationFallbackLocale: 'en'
@@ -747,7 +743,7 @@ const api = new ParseServer({
747743
...otherOptions,
748744

749745
pages: {
750-
enableRouter: true, // Enables the experimental feature; required for localization
746+
enableRouter: true,
751747
placeholders: {
752748
exampleKey: 'exampleValue'
753749
}
@@ -761,7 +757,7 @@ const api = new ParseServer({
761757
...otherOptions,
762758

763759
pages: {
764-
enableRouter: true, // Enables the experimental feature; required for localization
760+
enableRouter: true,
765761
placeholders: async (params) => {
766762
const value = await doSomething(params.locale);
767763
return {
@@ -781,7 +777,7 @@ The following parameter and placeholder keys are reserved because they are used
781777
| Parameter | Optional | Type | Default value | Example values | Environment variable | Description |
782778
|-------------------------------------------------|----------|---------------------------------------|----------------------------------------|------------------------------------------------------|-----------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
783779
| `pages` | yes | `Object` | `undefined` | - | `PARSE_SERVER_PAGES` | The options for pages such as password reset and email verification. |
784-
| `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.** |
780+
| `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. |
785781
| `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. |
786782
| `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. |
787783
| `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. |

src/Options/Definitions.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,7 @@ module.exports.ParseServerOptions = {
414414
},
415415
pages: {
416416
env: 'PARSE_SERVER_PAGES',
417-
help:
418-
'The options for pages such as password reset and email verification. Caution, this is an experimental feature that may not be appropriate for production.',
417+
help: 'The options for pages such as password reset and email verification.',
419418
action: parsers.objectParser,
420419
type: 'PagesOptions',
421420
default: {},
@@ -698,7 +697,7 @@ module.exports.PagesOptions = {
698697
enableRouter: {
699698
env: 'PARSE_SERVER_PAGES_ENABLE_ROUTER',
700699
help:
701-
'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.',
700+
'Is true if the pages router should be enabled; this is required for any of the pages options to take effect.',
702701
action: parsers.booleanParser,
703702
default: false,
704703
},

src/Options/docs.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Options/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export interface ParseServerOptions {
217217
/* Public URL to your parse server with http:// or https://.
218218
:ENV: PARSE_PUBLIC_SERVER_URL */
219219
publicServerURL: ?string;
220-
/* The options for pages such as password reset and email verification. Caution, this is an experimental feature that may not be appropriate for production.
220+
/* The options for pages such as password reset and email verification.
221221
:DEFAULT: {} */
222222
pages: ?PagesOptions;
223223
/* custom pages for password validation and reset
@@ -377,7 +377,7 @@ export interface SecurityOptions {
377377
}
378378

379379
export interface PagesOptions {
380-
/* 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.
380+
/* Is true if the pages router should be enabled; this is required for any of the pages options to take effect.
381381
:DEFAULT: false */
382382
enableRouter: ?boolean;
383383
/* Is true if pages should be localized; this has no effect on custom page redirects.

src/Routers/PublicAPIRouter.js

+8
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@ import path from 'path';
55
import fs from 'fs';
66
import qs from 'querystring';
77
import { Parse } from 'parse/node';
8+
import Deprecator from '../Deprecator/Deprecator';
89

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

1213
export class PublicAPIRouter extends PromiseRouter {
14+
constructor() {
15+
super();
16+
Deprecator.logRuntimeDeprecation({
17+
usage: 'PublicAPIRouter',
18+
solution: 'pages.enableRouter'
19+
});
20+
}
1321
verifyEmail(req) {
1422
const { username, token: rawToken } = req.query;
1523
const token = rawToken && typeof rawToken !== 'string' ? rawToken.toString() : rawToken;

0 commit comments

Comments
 (0)