You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: config.js
+55-28Lines changed: 55 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,15 @@ const fs = require('fs')
4
4
constDATABASE_SCHEMA={
5
5
authDatabase: {
6
6
default: '',
7
-
doc: 'The database to authenticate against when supplying a username and password',
7
+
doc:
8
+
'The database to authenticate against when supplying a username and password',
8
9
envTemplate: 'DB_{database}_AUTH_SOURCE',
9
10
format: String
10
11
},
11
12
authMechanism: {
12
13
default: '',
13
-
doc: 'If no authentication mechanism is specified or the mechanism DEFAULT is specified, the driver will attempt to authenticate using the SCRAM-SHA-1 authentication method if it is available on the MongoDB server. If the server does not support SCRAM-SHA-1 the driver will authenticate using MONGODB-CR.',
14
+
doc:
15
+
'If no authentication mechanism is specified or the mechanism DEFAULT is specified, the driver will attempt to authenticate using the SCRAM-SHA-1 authentication method if it is available on the MongoDB server. If the server does not support SCRAM-SHA-1 the driver will authenticate using MONGODB-CR.',
14
16
envTemplate: 'DB_{database}_AUTH_MECHANISM',
15
17
format: String
16
18
},
@@ -21,7 +23,8 @@ const DATABASE_SCHEMA = {
21
23
format: Boolean
22
24
},
23
25
hosts: {
24
-
default: 'Comma-separated string of MongoDB hosts, including port (e.g. localhost,localhost:27018,localhost:27019)',
26
+
default:
27
+
'Comma-separated string of MongoDB hosts, including port (e.g. localhost,localhost:27018,localhost:27019)',
25
28
doc: 'Database hosts',
26
29
format: String,
27
30
envTemplate: 'DB_{database}_HOSTS'
@@ -44,8 +47,15 @@ const DATABASE_SCHEMA = {
44
47
envTemplate: 'DB_{database}_PASSWORD'
45
48
},
46
49
readPreference: {
47
-
doc: 'How MongoDB routes read operations to the members of a replica set - see https://docs.mongodb.com/manual/reference/read-preference/',
`The current MongoDB configuration uses a \`databases\` object. This syntax has been deprecated and will be removed in a future release. Please update your database configuration to:\n\n${exampleConfig}`
@@ -146,16 +163,22 @@ const loadConfig = () => {
146
163
if(database.id===data.database){
147
164
data.databases[index].default=true
148
165
149
-
constexampleConfig=JSON.stringify({
150
-
databases: data.databases
151
-
},null,2)
152
-
166
+
constexampleConfig=JSON.stringify(
167
+
{
168
+
databases: data.databases
169
+
},
170
+
null,
171
+
2
172
+
)
173
+
153
174
console.warn(
154
175
`The current MongoDB configuration uses a \`database\` property to indicate the default database. This syntax has been deprecated and will be removed in a future release. Please update your database configuration to:\n\n${exampleConfig}`
`The current MongoDB configuration uses a \`hosts\` array at the root level. This syntax has been deprecated and will be removed in a future release. Please update your database configuration to:\n\n${exampleConfig}`
@@ -192,15 +219,15 @@ const loadConfig = () => {
192
219
193
220
// Validating databases.
194
221
constdatabases=mainConfig.get('databases')
195
-
222
+
196
223
databases.forEach((database,databaseIndex)=>{
197
224
constdatabaseConfig=convict(DATABASE_SCHEMA)
198
-
225
+
199
226
databaseConfig.load(database)
200
227
databaseConfig.validate()
201
-
228
+
202
229
constschema=databaseConfig.getSchema().properties
203
-
230
+
204
231
// Listening for database-specific environment variables.
0 commit comments