Enable direct access by default (#6636)

* enabled direct access by default

* removed obsolete direct access option test case

* quick fix test

* Set RESTController during tests

* Properly handle RESTController

* Documentation

* revert changes

* rerun tests

* remove extra parse instance

* Revert "remove extra parse instance"

This reverts commit 21422f45f1548ebddddd1c4ccbc03a94b4994429.

* Ensure restcontroller is set

* Fix test

* improved option docs

* renamed direct access env var

* added deprecations to README

* added deprecation definition

* fixed docs typo

* improve promise rejection warning test

* added renaming of env var to deprecation warning

Co-authored-by: Diamond Lewis <findlewis@gmail.com>
This commit is contained in:
Manuel
2021-04-05 02:28:28 +02:00
committed by GitHub
parent 70e1347623
commit 7042552507
10 changed files with 39 additions and 11 deletions

View File

@@ -8,7 +8,18 @@
* or set to an empty string if the current key will be removed without replacement.
* - `changeNewDefault`: Set the new default value if the key's default value
* will change in a future version.
* - `solution`: The instruction to resolve this deprecation warning. Optional. This
* instruction must not include the deprecation warning which is auto-generated.
* It should only contain additional instruction regarding the deprecation if
* necessary.
*
* If there are no deprecations this must return an empty array anyway.
* If there are no deprecations, this must return an empty array.
*/
module.exports = [];
module.exports = [
{
optionKey: 'directAccess',
changeNewDefault: 'true',
solution:
"Additionally, the environment variable 'PARSE_SERVER_ENABLE_EXPERIMENTAL_DIRECT_ACCESS' will be deprecated and renamed to 'PARSE_SERVER_DIRECT_ACCESS' in a future version; it is currently possible to use either one.",
},
];

View File

@@ -16,12 +16,13 @@ class Deprecator {
// Scan for deprecations
for (const deprecation of Deprecator._getDeprecations()) {
// Get deprecation properties
const solution = deprecation.solution;
const optionKey = deprecation.optionKey;
const changeNewDefault = deprecation.changeNewDefault;
// If default will change, only throw a warning if option is not set
if (changeNewDefault != null && options[optionKey] == null) {
Deprecator._log({ optionKey, changeNewDefault });
Deprecator._log({ optionKey, changeNewDefault, solution });
}
}
}

View File

@@ -110,9 +110,9 @@ module.exports.ParseServerOptions = {
default: 'mongodb://localhost:27017/parse',
},
directAccess: {
env: 'PARSE_SERVER_ENABLE_EXPERIMENTAL_DIRECT_ACCESS',
env: 'PARSE_SERVER_DIRECT_ACCESS',
help:
'Replace HTTP Interface when using JS SDK in current node runtime, defaults to false. Caution, this is an experimental feature that may not be appropriate for production.',
'Set to `true` if Parse requests within the same Node.js environment as Parse Server should be routed to Parse Server directly instead of via the HTTP interface. Default is `false`.<br><br>If set to `false` then Parse requests within the same Node.js environment as Parse Server are executed as HTTP requests sent to Parse Server via the `serverURL`. For example, a `Parse.Query` in Cloud Code is calling Parse Server via a HTTP request. The server is essentially making a HTTP request to itself, unnecessarily using network resources such as network ports.<br><br>\u26A0\uFE0F In environments where multiple Parse Server instances run behind a load balancer and Parse requests within the current Node.js environment should be routed via the load balancer and distributed as HTTP requests among all instances via the `serverURL`, this should be set to `false`.',
action: parsers.booleanParser,
default: false,
},

View File

@@ -20,7 +20,7 @@
* @property {Adapter<StorageAdapter>} databaseAdapter Adapter module for the database
* @property {DatabaseOptions} databaseOptions Options to pass to the database client
* @property {String} databaseURI The full URI to your database. Supported databases are mongodb or postgres.
* @property {Boolean} directAccess Replace HTTP Interface when using JS SDK in current node runtime, defaults to false. Caution, this is an experimental feature that may not be appropriate for production.
* @property {Boolean} directAccess Set to `true` if Parse requests within the same Node.js environment as Parse Server should be routed to Parse Server directly instead of via the HTTP interface. Default is `false`.<br><br>If set to `false` then Parse requests within the same Node.js environment as Parse Server are executed as HTTP requests sent to Parse Server via the `serverURL`. For example, a `Parse.Query` in Cloud Code is calling Parse Server via a HTTP request. The server is essentially making a HTTP request to itself, unnecessarily using network resources such as network ports.<br><br>⚠️ In environments where multiple Parse Server instances run behind a load balancer and Parse requests within the current Node.js environment should be routed via the load balancer and distributed as HTTP requests among all instances via the `serverURL`, this should be set to `false`.
* @property {String} dotNetKey Key for Unity and .Net SDK
* @property {Adapter<MailAdapter>} emailAdapter Adapter module for email sending
* @property {Boolean} emailVerifyTokenReuseIfValid an existing email verify token should be reused when resend verification email is requested

View File

@@ -165,8 +165,11 @@ export interface ParseServerOptions {
/* Sets the maximum size for the in memory cache, defaults to 10000
:DEFAULT: 10000 */
cacheMaxSize: ?number;
/* Replace HTTP Interface when using JS SDK in current node runtime, defaults to false. Caution, this is an experimental feature that may not be appropriate for production.
:ENV: PARSE_SERVER_ENABLE_EXPERIMENTAL_DIRECT_ACCESS
/* Set to `true` if Parse requests within the same Node.js environment as Parse Server should be routed to Parse Server directly instead of via the HTTP interface. Default is `false`.
<br><br>
If set to `false` then Parse requests within the same Node.js environment as Parse Server are executed as HTTP requests sent to Parse Server via the `serverURL`. For example, a `Parse.Query` in Cloud Code is calling Parse Server via a HTTP request. The server is essentially making a HTTP request to itself, unnecessarily using network resources such as network ports.
<br><br>
⚠️ In environments where multiple Parse Server instances run behind a load balancer and Parse requests within the current Node.js environment should be routed via the load balancer and distributed as HTTP requests among all instances via the `serverURL`, this should be set to `false`.
:DEFAULT: false */
directAccess: ?boolean;
/* Enables the default express error handler for all errors

View File

@@ -119,7 +119,7 @@ function ParseServerRESTController(applicationId, router) {
applicationId: applicationId,
sessionToken: options.sessionToken,
installationId: options.installationId,
context: options.context || {}, // Add context
context: options.context || {},
},
query,
};
@@ -155,6 +155,7 @@ function ParseServerRESTController(applicationId, router) {
return {
request: handleRequest,
ajax: RESTController.ajax,
handleError: RESTController.handleError,
};
}