Skip to content

Commit

Permalink
use alternate uri if mongo username is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas committed Jan 11, 2021
1 parent 083a3af commit cb2ddc7
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ function testConfig(config, name) {

const DEBUG = process.env.DEBUG || false;

const { PUBLIC_URL } = process.env;
testConfig(PUBLIC_URL, 'PUBLIC_URL');
// const { PUBLIC_URL } = process.env;
// testConfig(PUBLIC_URL, 'PUBLIC_URL');

const { FRONT_PORT } = process.env;
testConfig(FRONT_PORT, 'FRONT_PORT');
Expand Down Expand Up @@ -70,12 +70,19 @@ testConfig(MONGO_PORT, 'MONGO_PORT');
const { MONGO_HOST } = process.env;
testConfig(MONGO_HOST, 'MONGO_HOST');

const { MONGO_USERNAME } = process.env;
const { MONGO_DB_NAME } = process.env;
testConfig(MONGO_DB_NAME, 'MONGO_DB_NAME');

const { MONGO_USERNAME } = process.env;
const { MONGO_PASSWORD } = process.env;

const { MONGO_DB_NAME } = process.env;
testConfig(MONGO_DB_NAME, 'MONGO_DB_NAME');
let MONGO_URI;
if (MONGO_USERNAME) {
testConfig(MONGO_PASSWORD, 'MONGO_PASSWORD');
MONGO_URI = `mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}/${MONGO_DB_NAME}`;
} else {
MONGO_URI = `mongodb://${MONGO_HOST}:${MONGO_PORT}/${MONGO_DB_NAME}`;
}

const { AUTH_SECRET } = process.env;
testConfig(AUTH_SECRET, 'AUTH_SECRET');
Expand All @@ -88,7 +95,7 @@ testConfig(GITHUB_CLIENT_SECRET, 'GITHUB_CLIENT_SECRET');

module.exports = {
DEBUG,
PUBLIC_URL,
// PUBLIC_URL,
FRONT_PORT,
API_URL,
APP_PORT,
Expand All @@ -107,7 +114,7 @@ module.exports = {
PARSE_DASHBOARD_ROOT_PWD,
PARSE_SANDBOX: true,
PARSE_SILENT: false,
MONGO_URI: `mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_HOST}:${MONGO_PORT}/${MONGO_DB_NAME}`,
MONGO_URI,
AUTH_SECRET,
GITHUB_CLIENT_ID,
GITHUB_CLIENT_SECRET,
Expand Down

0 comments on commit cb2ddc7

Please sign in to comment.