From 81e6e1960db3866fd9f35f80255f6f6a66234d51 Mon Sep 17 00:00:00 2001 From: Giuseppe Raffa <77052701+sesee3@users.noreply.github.com> Date: Tue, 14 Apr 2026 18:10:03 +0200 Subject: [PATCH] fix: refactor database connection configuration to use baseConfig --- realtime/src/store/db.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/realtime/src/store/db.js b/realtime/src/store/db.js index bc92cb9..8ff2139 100644 --- a/realtime/src/store/db.js +++ b/realtime/src/store/db.js @@ -1,6 +1,6 @@ const { Pool } = require('pg'); -const pool = new Pool({ +const baseConfig = { user: process.env.DB_USER, password: process.env.DB_PSW, host: process.env.DB_HOST, @@ -8,20 +8,17 @@ const pool = new Pool({ max: 10, idleTimeoutMillis: 30000, connectionTimeoutMillis: 5000, -}) +}; const dbs = { data: { name: process.env.DATA_DB }, sensors: { name: process.env.SENSORS_DB } } -console.log('DB_PSW type:', typeof process.env.DB_PSW, 'value:', process.env.DB_PSW); -console.log('Pool password type:', typeof pool.options.password, 'value:', pool.options.password); - function getPool(db) { const dbConfig = dbs[db]; if (!dbConfig) throw new Error(`Database ${db} not configured`); - return new Pool({ ...pool.options, database: dbConfig.name }); + return new Pool({ ...baseConfig, database: dbConfig.name }); } async function checkConnection(db) {