1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-06 03:50:04 +02:00

Load devices with Oboe.

This commit is contained in:
Simo Kinnunen 2014-01-31 05:10:38 +09:00
parent c119e2c3d2
commit 4c45a7288b
3 changed files with 30 additions and 7 deletions

View file

@ -97,12 +97,17 @@ module.exports = function(options) {
.then(function(cursor) {
return Promise.promisify(cursor.toArray, cursor)()
.then(function(list) {
res.json(list)
res.json({
success: true
, devices: list
})
})
})
.catch(function(err) {
log.error('Failed to load device list: ', err.stack)
res.send(500)
res.json(500, {
success: false
})
})
})
@ -110,15 +115,22 @@ module.exports = function(options) {
dbapi.loadDevice(req.params.serial)
.then(function(device) {
if (device) {
res.json(device)
res.json({
success: true
, device: device
})
}
else {
res.send(404)
res.json(404, {
success: false
})
}
})
.catch(function(err) {
log.error('Failed to load device "%s": ', req.params.serial, err.stack)
res.send(500)
res.json(500, {
success: false
})
})
})