From 08f73445e9a94f304333a6eaf7838f5bba8e63cf Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Thu, 5 Sep 2019 12:51:01 +0200 Subject: [PATCH] add ENV variables for DB credentials to override sequelize config --- app/helpers/awsEmail.js | 1 - app/models/index.js | 5 +++++ development.env | 15 ++++++++++----- index.js | 2 ++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/helpers/awsEmail.js b/app/helpers/awsEmail.js index 9ca4bcb..24544d6 100644 --- a/app/helpers/awsEmail.js +++ b/app/helpers/awsEmail.js @@ -1,4 +1,3 @@ -const dotenv = require("dotenv").config(); const { getRealEstateTypeEnum } = require("./enums"); const { getRegionName, getMunicipalityName } = require("./codes"); const { allRERequestByUiid } = require("./db/dbHelper"); diff --git a/app/models/index.js b/app/models/index.js index e7926d0..ac4279a 100644 --- a/app/models/index.js +++ b/app/models/index.js @@ -8,6 +8,11 @@ const env = process.env.NODE_ENV || "development"; const config = require(__dirname + "/../config/config.json")[env]; const db = {}; +config.username = process.env.DB_USERNAME || config.username; +config.password = process.env.DB_PASSWORD || config.password; +config.database = process.env.DB_NAME || config.database; +config.port = process.env.DB_PORT || config.port; + let sequelize; if (config.use_env_variable) { sequelize = new Sequelize(process.env[config.use_env_variable], config); diff --git a/development.env b/development.env index 3980ba3..d14d427 100644 --- a/development.env +++ b/development.env @@ -1,5 +1,10 @@ - AMAZON_ACCES_KEY_ID=(your-key-here) - AMAZON_SECRET_ACCESS_KEY=(your-key-here) - AMAZON_REGION=eu-west-1 - APP_URL=http://localhost:3001 - SOURCE_EMAIL=info@saburly.com \ No newline at end of file +DB_USERNAME=Username for the database +DB_PASSWORD=Password for the database +DB_NAME=Database name +DB_PORT=Database port + +AMAZON_ACCES_KEY_ID=(your-key-here) +AMAZON_SECRET_ACCESS_KEY=(your-key-here) +AMAZON_REGION=eu-west-1 +APP_URL=http://localhost:3001 +SOURCE_EMAIL=info@saburly.com diff --git a/index.js b/index.js index 5e9ad28..39d4049 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,5 @@ +require("dotenv").config(); + const welcome = require("./app/controllers/welcome").getWelcome; const { getRealEstateTypes,