From b2cf8cf3360b58e64d519b02a5f06b469248b05c Mon Sep 17 00:00:00 2001 From: dm Date: Thu, 7 Jan 2021 14:54:24 +0100 Subject: [PATCH] change to unindented config definition --- config/default.json | 10 ++++------ models/db.js | 32 ++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/config/default.json b/config/default.json index 3fbea80..f9062ba 100644 --- a/config/default.json +++ b/config/default.json @@ -8,12 +8,10 @@ "invite_code": "top-sekrit", "storage_type": "postgres", - "storage_config": { - "host": "localhost", - "database": "spacedeck", - "username": "postgres", - "password": "postgres" - }, + "storage_postgres_host": "localhost", + "storage_postgres_database": "spacedeck", + "storage_postgres_username": "postgres", + "storage_postgres_password": "postgres", "storage_local_path": "./storage", "storage_local_db": "./database.sqlite", diff --git a/models/db.js b/models/db.js index bdb90a7..40eb52d 100644 --- a/models/db.js +++ b/models/db.js @@ -10,20 +10,24 @@ let sequelize; if(config.has('storage_type') && config.get('storage_type') === 'postgres') { console.log('connecting to postgres'); - let postgresConfig = config.get('storage_config'); - sequelize = new Sequelize(postgresConfig.database, postgresConfig.username, postgresConfig.password, { - host: postgresConfig.host, - dialect: 'postgres', - pool: { - max: 5, - min: 0, - acquire: 30000, - idle: 10000 - }, - logging: sequel_log, - // http://docs.sequelizejs.com/manual/tutorial/querying.html#operators - operatorsAliases: false - }); + sequelize = new Sequelize( + config.get('storage_postgres_database'), + config.get('storage_postgres_username'), + config.get('storage_postgres_password'), + { + host: config.get('storage_postgres_host'), + dialect: 'postgres', + pool: { + max: 5, + min: 0, + acquire: 30000, + idle: 10000 + }, + logging: sequel_log, + // http://docs.sequelizejs.com/manual/tutorial/querying.html#operators + operatorsAliases: false + } + ); } else { console.log('connecting to sqlite');