Skip to content

Commit

Permalink
feat(#2): add route to retrieve a monitoring event
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusbsilva committed Jun 28, 2019
1 parent 48e5a0e commit 17fb74e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ app.post('/monitoring_event', (req, res) => {
})
})

app.get('/monitoring_event/:id', (req, res) => {
MonitoringEventModel.findById(req.params.id)
.then((event) => {
if(!event) {
return res.status(404).send({
error: 'Event not found'
})
}

return res.status(200).send(event)
})
.catch((err) => {
if(err.kind === 'ObjectId') {
return res.status(400).send(err)
}

return res.status(500).send(err)
})
})

app.get('/monitoring_event', (req, res) => {
MonitoringEventModel.find({}, (err, events) => {
if(err){
Expand Down

0 comments on commit 17fb74e

Please sign in to comment.