first commit

This commit is contained in:
2025-06-21 15:13:58 -05:00
commit 07f75bbd93
37 changed files with 3125 additions and 0 deletions

37
db.js Normal file
View File

@ -0,0 +1,37 @@
const { Pool } = require('pg');
require('dotenv').config();
const pool = new Pool({
host: process.env.PGHOST,
user: process.env.PGUSER,
database: process.env.PGDATABASE,
password: process.env.PGPASSWORD,
port: process.env.PGPORT,
});
async function connectDB() {
try {
await pool.connect();
console.log('Database connected.')
} catch (error) {
console.error('Failed to connect to the database: ',error)
process.exit(1)
}
}
function closeDB() {
try {
pool.end();
console.log('Database connection closed.')
} catch (error) {
console.error('Error closing the database: ', error )
}
}
module.exports = {
query: (text, params) => pool.query(text, params),
closeDB,
connectDB
};