Add /api/customers endpoint in admin

This commit is contained in:
goga-m 2017-09-15 17:27:34 +03:00 committed by Josh Harvey
parent 685b327fb6
commit f8f7f87cca
2 changed files with 13 additions and 1 deletions

View file

@ -27,6 +27,7 @@ const login = require('./login')
const pairing = require('./pairing') const pairing = require('./pairing')
const server = require('./server') const server = require('./server')
const transactions = require('./transactions') const transactions = require('./transactions')
const customers = require('../customers')
const funding = require('./funding') const funding = require('./funding')
const NEVER = new Date(Date.now() + 100 * T.years) const NEVER = new Date(Date.now() + 100 * T.years)
@ -168,6 +169,12 @@ app.patch('/api/transaction/:id', (req, res, next) => {
.catch(() => res.status(404).send({Error: 'Not found'})) .catch(() => res.status(404).send({Error: 'Not found'}))
}) })
app.get('/api/customers', (req, res, next) => {
return customers.batch()
.then(r => res.send({customers: r}))
.catch(next)
})
app.use((err, req, res, next) => { app.use((err, req, res, next) => {
console.error(err) console.error(err)

View file

@ -32,4 +32,9 @@ function getDailyVolume (id) {
}) })
} }
module.exports = { add, get } function batch () {
const sql = 'select * from customers'
return db.any(sql)
}
module.exports = { add, get, batch }