Add Single Customer endpoint
This commit is contained in:
parent
ebc346c6ae
commit
0f5dfaa513
3 changed files with 246 additions and 75 deletions
|
|
@ -175,6 +175,14 @@ app.get('/api/customers', (req, res, next) => {
|
|||
.catch(next)
|
||||
})
|
||||
|
||||
app.get('/api/customer/:id', (req, res, next) => {
|
||||
return customers.getById(req.params.id)
|
||||
.then(r => {
|
||||
if (!r) return res.status(404).send({Error: 'Not found'})
|
||||
return res.send(r)
|
||||
})
|
||||
})
|
||||
|
||||
app.use((err, req, res, next) => {
|
||||
console.error(err)
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@ function get (phone) {
|
|||
})
|
||||
}
|
||||
|
||||
function getById (id) {
|
||||
const sql = 'select * from customers where id=$1'
|
||||
return db.oneOrNone(sql, [id])
|
||||
}
|
||||
|
||||
function getDailyVolume (id) {
|
||||
return Promise.all([
|
||||
db.one(`select coalesce(sum(fiat), 0) as total from cash_in_txs
|
||||
|
|
@ -41,4 +46,4 @@ function batch () {
|
|||
return db.any(sql, [ anonymous.uuid, NUM_RESULTS ])
|
||||
}
|
||||
|
||||
module.exports = { add, get, batch }
|
||||
module.exports = { add, get, batch, getById }
|
||||
|
|
|
|||
306
public/elm.js
306
public/elm.js
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue