Skip to content

Commit 9839189

Browse files
committed
improved contribution guide for parameter groups
1 parent dcb91ee commit 9839189

File tree

2 files changed

+35
-21
lines changed

2 files changed

+35
-21
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,13 @@ Introducing new Parse Errors requires the following steps:
189189
Introducing new [Parse Server configuration][config] parameters requires the following steps:
190190

191191
1. Add parameters definitions in [/src/Options/index.js][config-index].
192-
1. If a nested configuration object has been added, add the environment variable option prefix to `getENVPrefix` in [/resources/buildConfigDefinition.js](https://github.com/parse-community/parse-server/blob/master/resources/buildConfigDefinition.js).
193-
1. Execute `npm run definitions` to automatically create the definitions in [/src/Options/Definitions.js][config-def] and [/src/Options/docs.js][config-docs].
194-
1. Add parameter value validation in [/src/Config.js](https://github.com/parse-community/parse-server/blob/master/src/Config.js).
195-
1. Add test cases to ensure the correct parameter value validation. Parse Server throws an error at launch if an invalid value is set for any configuration parameter.
196-
1. Execute `npm run docs` to generate the documentation in the `/out` directory. Take a look at the documentation whether the description and formatting of the newly introduced parameters is satisfactory.
192+
2. If a parameter group (nested parameter) has been added:
193+
- add the environment variable prefix for the parameter group to `nestedOptionEnvPrefix` in [/resources/buildConfigDefinition.js](https://github.com/parse-community/parse-server/blob/master/resources/buildConfigDefinition.js)
194+
- add the parameter group type to `nestedOptionTypes` in [/resources/buildConfigDefinition.js](https://github.com/parse-community/parse-server/blob/master/resources/buildConfigDefinition.js)
195+
3. Execute `npm run definitions` to automatically create the definitions in [/src/Options/Definitions.js][config-def] and [/src/Options/docs.js][config-docs].
196+
4. Add parameter value validation in [/src/Config.js](https://github.com/parse-community/parse-server/blob/master/src/Config.js).
197+
5. Add test cases to ensure the correct parameter value validation. Parse Server throws an error at launch if an invalid value is set for any configuration parameter.
198+
6. Execute `npm run docs` to generate the documentation in the `/out` directory. Take a look at the documentation whether the description and formatting of the newly introduced parameters is satisfactory.
197199

198200
## Code of Conduct
199201

resources/buildConfigDefinitions.js

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,31 @@
1111
*/
1212
const parsers = require('../src/Options/parsers');
1313

14+
// The types of nested options.
15+
const nestedOptionTypes = [
16+
'Object',
17+
'PasswordPolicyOptions',
18+
'IdempotencyOptions',
19+
'FileUploadOptions',
20+
'CustomPagesOptions',
21+
'PagesCustomUrlsOptions',
22+
'PagesOptions'
23+
];
24+
25+
// The prefix of environment variables for nested options.
26+
const nestedOptionEnvPrefix = {
27+
'ParseServerOptions' : 'PARSE_SERVER_',
28+
'PagesOptions' : 'PARSE_SERVER_PAGES_',
29+
'PagesCustomUrlsOptions' : 'PARSE_SERVER_PAGES_CUSTOM_URL_',
30+
'CustomPagesOptions' : 'PARSE_SERVER_CUSTOM_PAGES_',
31+
'LiveQueryServerOptions' : 'PARSE_LIVE_QUERY_SERVER_',
32+
'LiveQueryOptions' : 'PARSE_SERVER_LIVEQUERY_',
33+
'IdempotencyOptions' : 'PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_',
34+
'AccountLockoutOptions' : 'PARSE_SERVER_ACCOUNT_LOCKOUT_',
35+
'PasswordPolicyOptions' : 'PARSE_SERVER_PASSWORD_POLICY_',
36+
'FileUploadOptions' : 'PARSE_SERVER_FILE_UPLOAD_',
37+
}
38+
1439
function last(array) {
1540
return array[array.length - 1];
1641
}
@@ -40,20 +65,8 @@ function getCommentValue(comment) {
4065
}
4166

4267
function getENVPrefix(iface) {
43-
const options = {
44-
'ParseServerOptions' : 'PARSE_SERVER_',
45-
'PagesOptions' : 'PARSE_SERVER_PAGES_',
46-
'PagesCustomUrlsOptions' : 'PARSE_SERVER_PAGES_CUSTOM_URL_',
47-
'CustomPagesOptions' : 'PARSE_SERVER_CUSTOM_PAGES_',
48-
'LiveQueryServerOptions' : 'PARSE_LIVE_QUERY_SERVER_',
49-
'LiveQueryOptions' : 'PARSE_SERVER_LIVEQUERY_',
50-
'IdempotencyOptions' : 'PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_',
51-
'AccountLockoutOptions' : 'PARSE_SERVER_ACCOUNT_LOCKOUT_',
52-
'PasswordPolicyOptions' : 'PARSE_SERVER_PASSWORD_POLICY_',
53-
'FileUploadOptions' : 'PARSE_SERVER_FILE_UPLOAD_',
54-
}
55-
if (options[iface.id.name]) {
56-
return options[iface.id.name]
68+
if (nestedOptionEnvPrefix[iface.id.name]) {
69+
return nestedOptionEnvPrefix[iface.id.name]
5770
}
5871
}
5972

@@ -166,8 +179,7 @@ function parseDefaultValue(elt, value, t) {
166179
if (type == 'NumberOrBoolean') {
167180
literalValue = t.numericLiteral(parsers.numberOrBoolParser('')(value));
168181
}
169-
const literalTypes = ['Object', 'IdempotencyOptions','FileUploadOptions','CustomPagesOptions', 'PagesCustomUrlsOptions', 'PagesOptions'];
170-
if (literalTypes.includes(type)) {
182+
if (nestedOptionTypes.includes(type)) {
171183
const object = parsers.objectParser(value);
172184
const props = Object.keys(object).map((key) => {
173185
return t.objectProperty(key, object[value]);

0 commit comments

Comments
 (0)