colouring-montreal/app/src/db.js
2018-09-30 20:27:53 +01:00

25 lines
624 B
JavaScript

/**
* Expose query interface to database pool
*
* - connection details must be set in environment variables, default to:
* PGHOST='localhost'
* PGUSER=process.env.USER
* PGDATABASE=process.env.USER
* PGPASSWORD=null
* PGPORT=5432
*/
import pg from 'pg-promise';
// pg-promise, can provide initialisation options
const pgp = pg();
// database connection (default to env vars)
const db = pgp({
'host': process.env.PGHOST,
'dbname': process.env.PGDATABASE,
'user': process.env.PGUSER,
'password': process.env.PGPASSWORD,
'port': process.env.PGPORT
});
export default db;