diff --git a/routes/storage.js b/routes/storage.js index d2d2661d3e11b13a9255cfa19b95082b65576540..67cf835efc77c2d2700d354d4354607f72007e6a 100644 --- a/routes/storage.js +++ b/routes/storage.js @@ -20,7 +20,44 @@ mongoClient.connect(mongoUrl, function(err, db) { router.get('/:resource_id', function(req, res, next) { - res.sendStatus(200); + var _id = req.params.resource_id; + mongoClient.connect(mongoUrl, function(err, db) { + + if(err!=null){ + + debug(err); + next(err); + + }else{ + + var collection = db.collection('resources'); + + collection.find({"_id":_id}).limit(1).next(function(err, doc){ + + if(err!=null){ + + debug(err); + next(err); + + }else{ + + if(doc==undefined){ + + res.sendStatus(400); + + }else{ + + res.send(doc); + + } + + } + + }); + + } + + }); });