19 lines
391 B
JavaScript
19 lines
391 B
JavaScript
import dotenv from 'dotenv'
|
|
import pkg from 'pg'
|
|
const { Pool } = pkg
|
|
|
|
dotenv.config()
|
|
|
|
const pool = new Pool({
|
|
connectionString: process.env.DATABASE_URL,
|
|
// Optional SSL setting for hosted DBs (uncomment when needed)
|
|
// ssl: { rejectUnauthorized: false }
|
|
})
|
|
|
|
pool.on('error', (err) => {
|
|
console.error('Unexpected error on idle client', err)
|
|
process.exit(-1)
|
|
})
|
|
|
|
export { pool }
|
|
|