Database settings moved to own file in /config

This commit is contained in:
Lucas Patenaude
2024-05-03 02:47:55 -06:00
parent c3c2662b25
commit 4886632263
2 changed files with 30 additions and 28 deletions

24
config/database.js Normal file
View File

@@ -0,0 +1,24 @@
const pgp = require("pg-promise")();
// Database configuration
const dbConfig = {
host: "db",
port: 5432,
database: "users_db",
user: "postgres",
password: "pwd",
};
const db = pgp(dbConfig);
// Test database connection
db.connect()
.then((obj) => {
console.log("Database connection successful");
obj.done();
})
.catch((error) => {
console.log("ERROR:", error.message || error);
});
module.exports = db;