Skip to content

Instantly share code, notes, and snippets.

@rcdexta
Created January 2, 2019 03:37
Show Gist options
  • Save rcdexta/42b577385113334c952a5cebdc8971ef to your computer and use it in GitHub Desktop.
Save rcdexta/42b577385113334c952a5cebdc8971ef to your computer and use it in GitHub Desktop.
const { Client } = require('pg')
const pg = {
init: async function() {
const client = new Client({
user: process.env['DB_USER'] || 'postgres',
host: process.env['DB_HOST'] || 'localhost',
database: process.env['DB_NAME'] || 'customers',
password: process.env['DB_PASSWORD'] || '',
port: 5432
})
await client.connect();
return client;
}
}
module.exports = pg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment