add view single device routes/controller

This commit is contained in:
Francesco Esposito 2019-02-19 19:32:28 +01:00
parent f3842099e1
commit 673857ee52
2 changed files with 15 additions and 0 deletions

View File

@ -7,4 +7,8 @@ router
.route('/devices') .route('/devices')
.get(deviceController.index); .get(deviceController.index);
router
.route('/devices/:deviceId')
.get(deviceController.view);
module.exports = router; module.exports = router;

View File

@ -10,4 +10,15 @@ function index(req, res) {
}); });
} }
function view(req, res) {
Device.findById(req.params.deviceId)
.then((device) => {
res.json(device);
})
.catch((err) => {
res.send(err);
});
}
module.exports.index = index; module.exports.index = index;
module.exports.view = view;