From 12b32dbf3417225348b58c0cd519555f06039478 Mon Sep 17 00:00:00 2001 From: Rudi van Hierden Date: Wed, 24 Aug 2022 10:12:16 +0200 Subject: [PATCH] Add `MONGO_DB_CONNECTION_STRING` to override the connection string builder This avoids the need of having to specify the following environment variables: `MONGO_DB_HOST`, `MONGO_DB_PORT`, `MONGO_DB_USER`, `MONGO_DB_PASSWORD` and `MONGO_DB_AUTHSOURCE` and allows greater control of the connection string. --- app-init.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app-init.js b/app-init.js index 533132af..319fa0c3 100644 --- a/app-init.js +++ b/app-init.js @@ -40,6 +40,11 @@ const sessionStore = new MySQLStore({ function getMongoDbConnectionString () { + // Allow the connection string builder to be overridden by an environment variable + if (process.env.MONGO_DB_CONNECTION_STRING) { + return process.env.MONGO_DB_CONNECTION_STRING; + } + const host = process.env.MONGO_DB_HOST || 'localhost'; const port = process.env.MONGO_DB_PORT || 27017; const user = process.env.MONGO_DB_USER || '';