colouring-montreal/app/src/db.ts
Maciej Ziarkowski 4421930942 Squash TypeScript errors and fix bugs
Most errors highglighted by TS were due to a lack of type definitions
and were ignored by settings types to `any`.
Some minor bugs were resolved where the fix was obvious.
TODO marks left where `any` needs to be later removed or bugfix verified
2019-08-09 18:49:43 +01:00

25 lines
636 B
TypeScript

/**
* 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,
'database': process.env.PGDATABASE,
'user': process.env.PGUSER,
'password': process.env.PGPASSWORD,
'port': parseInt(process.env.PGPORT)
});
export default db;