add ENV variables for DB credentials to override sequelize config

This commit is contained in:
Bilal Catic
2019-09-05 12:51:01 +02:00
parent 60e618fd22
commit 08f73445e9
4 changed files with 17 additions and 6 deletions

View File

@@ -1,4 +1,3 @@
const dotenv = require("dotenv").config();
const { getRealEstateTypeEnum } = require("./enums");
const { getRegionName, getMunicipalityName } = require("./codes");
const { allRERequestByUiid } = require("./db/dbHelper");

View File

@@ -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);

View File

@@ -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
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

View File

@@ -1,3 +1,5 @@
require("dotenv").config();
const welcome = require("./app/controllers/welcome").getWelcome;
const {
getRealEstateTypes,