Skip to content

Commit 2f39a13

Browse files
committed
feat: Add query server options namespace with aggregation raw defaults
1 parent 34494ad commit 2f39a13

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

resources/buildConfigDefinitions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const nestedOptionTypes = [
2323
'PagesOptions',
2424
'PagesRoute',
2525
'PasswordPolicyOptions',
26+
'QueryServerOptions',
2627
'RequestComplexityOptions',
2728
'SecurityOptions',
2829
'SchemaOptions',
@@ -48,6 +49,7 @@ const nestedOptionEnvPrefix = {
4849
PagesRoute: 'PARSE_SERVER_PAGES_ROUTE_',
4950
ParseServerOptions: 'PARSE_SERVER_',
5051
PasswordPolicyOptions: 'PARSE_SERVER_PASSWORD_POLICY_',
52+
QueryServerOptions: 'PARSE_SERVER_QUERY_',
5153
RateLimitOptions: 'PARSE_SERVER_RATE_LIMIT_',
5254
RequestComplexityOptions: 'PARSE_SERVER_REQUEST_COMPLEXITY_',
5355
SchemaOptions: 'PARSE_SERVER_SCHEMA_',

src/Options/Definitions.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,13 @@ module.exports.ParseServerOptions = {
512512
help: 'Configuration for push, as stringified JSON. See http://docs.parseplatform.org/parse-server/guide/#push-notifications',
513513
action: parsers.objectParser,
514514
},
515+
query: {
516+
env: 'PARSE_SERVER_QUERY',
517+
help: 'Query-related server defaults.',
518+
action: parsers.objectParser,
519+
type: 'QueryServerOptions',
520+
default: {},
521+
},
515522
rateLimit: {
516523
env: 'PARSE_SERVER_RATE_LIMIT',
517524
help: "Options to limit repeated requests to Parse Server APIs. This can be used to protect sensitive endpoints such as `/requestPasswordReset` from brute-force attacks or Parse Server as a whole from denial-of-service (DoS) attacks.<br><br>\u2139\uFE0F Mind the following limitations:<br>- rate limits applied per IP address; this limits protection against distributed denial-of-service (DDoS) attacks where many requests are coming from various IP addresses<br>- if multiple Parse Server instances are behind a load balancer or ran in a cluster, each instance will calculate it's own request rates, independent from other instances; this limits the applicability of this feature when using a load balancer and another rate limiting solution that takes requests across all instances into account may be more suitable<br>- this feature provides basic protection against denial-of-service attacks, but a more sophisticated solution works earlier in the request flow and prevents a malicious requests to even reach a server instance; it's therefore recommended to implement a solution according to architecture and use case.",
@@ -778,6 +785,20 @@ module.exports.SecurityOptions = {
778785
default: false,
779786
},
780787
};
788+
module.exports.QueryServerOptions = {
789+
aggregationRawFieldNames: {
790+
env: 'PARSE_SERVER_QUERY_AGGREGATION_RAW_FIELD_NAMES',
791+
help: 'When `true`, all aggregation queries default to using native MongoDB field names (no automatic `createdAt` \u2192 `_created_at` rewriting). Individual queries can still override this via the `rawFieldNames` option. Default is `false`.',
792+
action: parsers.booleanParser,
793+
default: false,
794+
},
795+
aggregationRawValues: {
796+
env: 'PARSE_SERVER_QUERY_AGGREGATION_RAW_VALUES',
797+
help: 'When `true`, all aggregation queries default to using MongoDB Extended JSON (EJSON) for explicit value typing and skip schema-based value coercion. Individual queries can still override this via the `rawValues` option. Default is `false`.',
798+
action: parsers.booleanParser,
799+
default: false,
800+
},
801+
};
781802
module.exports.PagesOptions = {
782803
customRoutes: {
783804
env: 'PARSE_SERVER_PAGES_CUSTOM_ROUTES',

src/Options/docs.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Options/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ export interface ParseServerOptions {
391391
:ENV: PARSE_SERVER_REQUEST_COMPLEXITY
392392
:DEFAULT: {} */
393393
requestComplexity: ?RequestComplexityOptions;
394+
/* Query-related server defaults.
395+
:ENV: PARSE_SERVER_QUERY
396+
:DEFAULT: {} */
397+
query: ?QueryServerOptions;
394398
/* The security options to identify and report weak security settings.
395399
:DEFAULT: {} */
396400
security: ?SecurityOptions;
@@ -490,6 +494,17 @@ export interface SecurityOptions {
490494
checkGroups: ?(CheckGroup[]);
491495
}
492496

497+
export interface QueryServerOptions {
498+
/* When `true`, all aggregation queries default to using MongoDB Extended JSON (EJSON) for explicit value typing and skip schema-based value coercion. Individual queries can still override this via the `rawValues` option. Default is `false`.
499+
:ENV: PARSE_SERVER_QUERY_AGGREGATION_RAW_VALUES
500+
:DEFAULT: false */
501+
aggregationRawValues: ?boolean;
502+
/* When `true`, all aggregation queries default to using native MongoDB field names (no automatic `createdAt` → `_created_at` rewriting). Individual queries can still override this via the `rawFieldNames` option. Default is `false`.
503+
:ENV: PARSE_SERVER_QUERY_AGGREGATION_RAW_FIELD_NAMES
504+
:DEFAULT: false */
505+
aggregationRawFieldNames: ?boolean;
506+
}
507+
493508
export interface PagesOptions {
494509
/* Is true if pages should be localized; this has no effect on custom page redirects.
495510
:DEFAULT: false */

0 commit comments

Comments
 (0)