forked from SeifYounis/Medical-Imaging-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.js
More file actions
29 lines (22 loc) · 565 Bytes
/
db.js
File metadata and controls
29 lines (22 loc) · 565 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* Code for connecting to PostgreSQL database
*/
const { Pool } = require('pg')
let pool;
function connectToDB() {
if(!pool) {
// Create and connect a new PostgreSQL database connection pool
pool = new Pool({
connectionString: process.env.APP_DATABASE_URL,
ssl: {
rejectUnauthorized: false
}
})
pool.connect((err) => {
if(err) throw err;
console.log('PostgreSQL Connected');
})
}
return pool
}
module.exports = connectToDB()