control sequelize logging with env variable

This commit is contained in:
Bilal Catic
2019-07-24 07:20:05 +02:00
parent 4fefa3a08d
commit ac1c82c16b
4 changed files with 21 additions and 17 deletions

18
config/config.js Normal file
View File

@@ -0,0 +1,18 @@
module.exports = {
development: {
username: 'docker',
password: 'docker',
database: 'CrmIntegration',
port: '5431',
dialect: 'postgres',
logging: parseInt(process.env.SEQUELIZE_LOGGING) ? console.log : false
},
test: {
"use_env_variable": 'DATABASE_URL',
logging: parseInt(process.env.SEQUELIZE_LOGGING) ? console.log : false
},
production: {
"use_env_variable": 'DATABASE_URL',
logging: parseInt(process.env.SEQUELIZE_LOGGING) ? console.log : false
}
};

View File

@@ -1,16 +0,0 @@
{
"development": {
"username": "docker",
"password": "docker",
"database": "CrmIntegration",
"port": "5431",
"dialect": "postgres",
"logging": false
},
"test": {
"use_env_variable": "DATABASE_URL"
},
"production": {
"use_env_variable": "DATABASE_URL"
}
}

View File

@@ -22,3 +22,5 @@ UNLOCK_STREAK_REPAIR_AFTER=Number of months without incidents to reset user inci
BOOKING_CHANGE_PERCENTAGE_CHARGE=Percentage of hourly reate to apply for cancellation-like charges
ALLOWED_BOOKING_CANCELLATION_TIME=Time from creation (in minutes) in which cancellation is not charged
SEQUELIZE_LOGGING=0 - false, 1 - true (console logging)

View File

@@ -5,7 +5,7 @@ const path = require('path');
const Sequelize = require('sequelize');
const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.json')[env];
const config = require(__dirname + '/../config/config.js')[env];
const db = {};
let sequelize;