Add Single Customer endpoint

This commit is contained in:
goga-m 2017-09-20 20:07:39 +03:00 committed by Josh Harvey
parent ebc346c6ae
commit 0f5dfaa513
3 changed files with 246 additions and 75 deletions

View file

@ -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)