Create /logs/ api endpoint

This commit is contained in:
goga-m 2017-10-24 18:25:48 +03:00 committed by Josh Harvey
parent 43f578d311
commit 8ce22eca95
3 changed files with 156 additions and 146 deletions

View file

@ -191,6 +191,17 @@ app.get('/api/logs/:deviceId', (req, res, next) => {
.catch(next)
})
app.get('/api/logs', (req, res, next) => {
return machineLoader.getMachines()
.then(machines => {
const firstMachine = _.first(machines)
if (!firstMachine) return res.status(404).send({Error: 'No machines'})
return logs.getMachineLogs(firstMachine.deviceId)
.then(r => res.send(r))
})
.catch(next)
})
/**
* Endpoint for patching customer's data
*