()
| 77 | } |
| 78 | |
| 79 | function getConnectionStringFromEnvVariables() { |
| 80 | const infos = { |
| 81 | // server: mongodb hostname or IP address |
| 82 | // for replica set, use array of string instead |
| 83 | server: ( |
| 84 | meConfigMongodbServer.length > 1 ? meConfigMongodbServer : meConfigMongodbServer[0] |
| 85 | ) || mongo.host, |
| 86 | port: process.env.ME_CONFIG_MONGODB_PORT || mongo.port, |
| 87 | dbName: process.env.ME_CONFIG_MONGODB_AUTH_DATABASE || mongo.dbName, |
| 88 | |
| 89 | // >>>> If you are using an admin mongodb account, or no admin account exists, fill out section below |
| 90 | // >>>> Using an admin account allows you to view and edit all databases, and view stats |
| 91 | // leave username and password empty if no admin account exists |
| 92 | username: getFileEnv(adminUsername) || getFileEnv(dbAuthUsername) || mongo.username, |
| 93 | password: getFileEnv(adminPassword) || getFileEnv(dbAuthPassword) || mongo.password, |
| 94 | }; |
| 95 | const login = infos.username ? `${infos.username}:${infos.password}@` : ''; |
| 96 | return `mongodb://${login}${infos.server}:${infos.port}/${infos.dbName}`; |
| 97 | } |
| 98 | |
| 99 | function getBoolean(str, defaultValue = false) { |
| 100 | return str ? str.toLowerCase() === 'true' : defaultValue; |
no test coverage detected