MCPcopy Create free account
hub / github.com/mongo-express/mongo-express / getConnectionStringFromEnvVariables

Function getConnectionStringFromEnvVariables

config.default.js:79–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

77}
78
79function 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
99function getBoolean(str, defaultValue = false) {
100 return str ? str.toLowerCase() === 'true' : defaultValue;

Callers 1

config.default.jsFile · 0.85

Calls 1

getFileEnvFunction · 0.85

Tested by

no test coverage detected