Skip to content

Commit 406f237

Browse files
committed
Adds missing options to the CLI
1 parent bc384e9 commit 406f237

File tree

1 file changed

+67
-70
lines changed

1 file changed

+67
-70
lines changed

src/cli/cli-definitions.js

+67-70
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
function numberParser(key) {
2+
return function(opt) {
3+
opt = parseInt(opt);
4+
if (!Number.isInteger(opt)) {
5+
throw new Error(`The ${key} is invalid`);
6+
}
7+
return opt;
8+
}
9+
}
10+
11+
function objectParser(opt) {
12+
if (typeof opt == 'object') {
13+
return opt;
14+
}
15+
return JSON.parse(opt)
16+
}
17+
18+
function moduleOrObjectParser(opt) {
19+
if (typeof opt == 'object') {
20+
return opt;
21+
}
22+
try {
23+
return JSON.parse(opt);
24+
} catch(e) {}
25+
return opt;
26+
}
27+
28+
function booleanParser(opt) {
29+
if (opt == true || opt == "true" || opt == "1") {
30+
return true;
31+
}
32+
return false;
33+
}
34+
135
export default {
236
"appId": {
337
env: "PARSE_SERVER_APPLICATION_ID",
@@ -13,18 +47,21 @@ export default {
1347
env: "PORT",
1448
help: "The port to run the ParseServer. defaults to 1337.",
1549
default: 1337,
16-
action: function(opt) {
17-
opt = parseInt(opt);
18-
if (!Number.isInteger(opt)) {
19-
throw new Error("The port is invalid");
20-
}
21-
return opt;
22-
}
50+
action: numberParser("port")
2351
},
2452
"databaseURI": {
2553
env: "PARSE_SERVER_DATABASE_URI",
2654
help: "The full URI to your mongodb database"
2755
},
56+
"databaseOptions": {
57+
env: "PARSE_SERVER_DATABASE_OPTIONS",
58+
help: "Options to pass to the mongodb client",
59+
action: objectParser
60+
},
61+
"collectionPrefix": {
62+
env: "PARSE_SERVER_COLLECTION_PREFIX",
63+
help: 'A collection prefix for the classes'
64+
},
2865
"serverURL": {
2966
env: "PARSE_SERVER_URL",
3067
help: "URL to your parse server with http:// or https://.",
@@ -56,22 +93,12 @@ export default {
5693
"push": {
5794
env: "PARSE_SERVER_PUSH",
5895
help: "Configuration for push, as stringified JSON. See https://github.com/ParsePlatform/parse-server/wiki/Push",
59-
action: function(opt) {
60-
if (typeof opt == 'object') {
61-
return opt;
62-
}
63-
return JSON.parse(opt)
64-
}
96+
action: objectParser
6597
},
6698
"oauth": {
6799
env: "PARSE_SERVER_OAUTH_PROVIDERS",
68100
help: "Configuration for your oAuth providers, as stringified JSON. See https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide#oauth",
69-
action: function(opt) {
70-
if (typeof opt == 'object') {
71-
return opt;
72-
}
73-
return JSON.parse(opt)
74-
}
101+
action: objectParser
75102
},
76103
"fileKey": {
77104
env: "PARSE_SERVER_FILE_KEY",
@@ -88,22 +115,12 @@ export default {
88115
"enableAnonymousUsers": {
89116
env: "PARSE_SERVER_ENABLE_ANON_USERS",
90117
help: "Enable (or disable) anon users, defaults to true",
91-
action: function(opt) {
92-
if (opt == "true" || opt == "1") {
93-
return true;
94-
}
95-
return false;
96-
}
118+
action: booleanParser
97119
},
98120
"allowClientClassCreation": {
99121
env: "PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION",
100122
help: "Enable (or disable) client class creation, defaults to true",
101-
action: function(opt) {
102-
if (opt == "true" || opt == "1") {
103-
return true;
104-
}
105-
return false;
106-
}
123+
action: booleanParser
107124
},
108125
"mountPath": {
109126
env: "PARSE_SERVER_MOUNT_PATH",
@@ -113,65 +130,45 @@ export default {
113130
"filesAdapter": {
114131
env: "PARSE_SERVER_FILES_ADAPTER",
115132
help: "Adapter module for the files sub-system",
116-
action: function action(opt) {
117-
if (typeof opt == 'object') {
118-
return opt;
119-
}
120-
try {
121-
return JSON.parse(opt);
122-
} catch(e) {}
123-
return opt;
124-
}
133+
action: moduleOrObjectParser
125134
},
126135
"emailAdapter": {
127136
env: "PARSE_SERVER_EMAIL_ADAPTER",
128137
help: "Adapter module for the email sending",
129-
action: function action(opt) {
130-
if (typeof opt == 'object') {
131-
return opt;
132-
}
133-
try {
134-
return JSON.parse(opt);
135-
} catch(e) {}
136-
return opt;
137-
}
138+
action: moduleOrObjectParser
139+
},
140+
"verifyUserEmails": {
141+
env: "PARSE_SERVER_VERIFY_USER_EMAILS",
142+
help: "Enable (or disable) user email validation, defaults to false",
143+
action: booleanParser
144+
},
145+
"appName": {
146+
env: "PARSE_SERVER_APP_NAME",
147+
help: "Sets the app name"
138148
},
139149
"loggerAdapter": {
140150
env: "PARSE_SERVER_LOGGER_ADAPTER",
141151
help: "Adapter module for the logging sub-system",
142-
action: function action(opt) {
143-
if (typeof opt == 'object') {
144-
return opt;
145-
}
146-
try {
147-
return JSON.parse(opt);
148-
} catch(e) {}
149-
return opt;
150-
}
152+
action: moduleOrObjectParser
151153
},
152154
"liveQuery": {
153155
env: "PARSE_SERVER_LIVE_QUERY_OPTIONS",
154156
help: "liveQuery options",
155-
action: function action(opt) {
156-
if (typeof opt == 'object') {
157-
return opt;
158-
}
159-
return JSON.parse(opt);
160-
}
157+
action: objectParser
161158
},
162159
"customPages": {
163160
env: "PARSE_SERVER_CUSTOM_PAGES",
164161
help: "custom pages for pasword validation and reset",
165-
action: function action(opt) {
166-
if (typeof opt == 'object') {
167-
return opt;
168-
}
169-
return JSON.parse(opt);
170-
}
162+
action: objectParser
171163
},
172164
"maxUploadSize": {
173165
env: "PARSE_SERVER_MAX_UPLOAD_SIZE",
174166
help: "Max file size for uploads.",
175167
default: "20mb"
168+
},
169+
"sessionLength": {
170+
env: "PARSE_SERVER_SESSION_LENGTH",
171+
help: "Session duration, defaults to 1 year",
172+
action: numberParser("sessionLength")
176173
}
177174
};

0 commit comments

Comments
 (0)