refactor db connection string

This commit is contained in:
Josh Harvey 2016-06-12 13:19:00 +03:00
parent 944de6fab0
commit 91e0fed95d
9 changed files with 47 additions and 82 deletions

View file

@ -1,14 +1,8 @@
#!/usr/bin/env node
var fs = require('fs')
var pgp = require('pg-promise')()
var psqlUrl = require('../lib/options').postgres
var psqlUrl
try {
psqlUrl = process.env.DATABASE_URL || JSON.parse(fs.readFileSync('/etc/lamassu.json')).postgresql
} catch (ex) {
psqlUrl = 'psql://lamassu:lamassu@localhost/lamassu'
}
var db = pgp(psqlUrl)
db.manyOrNone(`select * from transactions where incoming=false