-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpool.js
28 lines (26 loc) · 766 Bytes
/
pool.js
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
28
const pg = require('pg');
let pool;
// When our app is deployed to the internet
// we'll use the DATABASE_URL environment variable
// to set the connection info: web address, username/password, db name
// eg:
// DATABASE_URL=postgresql://jDoe354:[email protected]/prime_app
if (process.env.DATABASE_URL) {
pool = new pg.Pool({
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false
}
});
}
// When we're running this app on our own computer
// we'll connect to the postgres database that is
// also running on our computer (localhost)
else {
pool = new pg.Pool({
host: 'localhost',
port: 5432,
database: 'saga_movies_weekend',
});
}
module.exports = pool;