From c5a79d6f964afcff56610a482eab821c685892ae Mon Sep 17 00:00:00 2001 From: Ally Shaban Date: Wed, 20 Dec 2023 14:13:36 +0300 Subject: [PATCH] setting database credentials inside config file --- .../lib/gofr-backend-site/config/default.json.example | 7 +++++++ gofr-backend/lib/modules/postgres.js | 11 ++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gofr-backend/lib/gofr-backend-site/config/default.json.example b/gofr-backend/lib/gofr-backend-site/config/default.json.example index 0289d9df..0f21784f 100644 --- a/gofr-backend/lib/gofr-backend-site/config/default.json.example +++ b/gofr-backend/lib/gofr-backend-site/config/default.json.example @@ -17,6 +17,13 @@ "path": "/var/lib/gofr/gofr-backend/lib" } }, + "database": { + "dbname": "hapi", + "username": "hapi", + "password": "hapi", + "host": "localhost", + "port": 5432 + }, "server": { "hostname": "0.0.0.0", "port": 4000 diff --git a/gofr-backend/lib/modules/postgres.js b/gofr-backend/lib/modules/postgres.js index aa3c5425..ce41701c 100644 --- a/gofr-backend/lib/modules/postgres.js +++ b/gofr-backend/lib/modules/postgres.js @@ -1,10 +1,11 @@ const { Pool, escapeLiteral } = require("pg"); +const config = require('../config'); const pool = new Pool({ - database: "gofr", - user: "hapi", - password: "hapi", - port: 5432, - host: "localhost", + database: config.get('database:dbname'), + user: config.get('database:username'), + password: config.get('database:password'), + port: config.get('database:port'), + host: config.get('database:host') }); module.exports = { pool, escapeLiteral }; \ No newline at end of file