Skip to content

Commit

Permalink
fix(database): account for env vars when connecting to Postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Kristian Flaatten committed Aug 31, 2016
1 parent 5483637 commit d4a7ae0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/pg.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

const pg = require('pg');

module.exports = new pg.Client('postgres://postgres:@postgres/postgres');
const opts = {
user: process.env.POSTGRES_USER || 'postgres',
password: process.env.POSTGRES_PASSWORD || '',
database: process.env.POSTGRES_DATABASE || 'postgres',
host: process.env.POSTGRES_PORT_5432_TCP_ADDR || 'postgres',
port: process.env.POSTGRES_PORT_5432_TCP_PORT || 5432,
};

module.exports = new pg.Client(opts);

module.exports.SQL = function SQL(parts, ...values) {
return {
Expand Down

0 comments on commit d4a7ae0

Please sign in to comment.