Commit 462c2a60 authored by andreagerino's avatar andreagerino

...

parent 7d1ec560
......@@ -3,6 +3,8 @@ var router = express.Router();
var debug = require('debug')('Icarus:server');
var mongoClient = require('mongodb').MongoClient;
var objectID = mongoClient.objectId;
var assert = assert = require('assert');
// Connection URL
......@@ -20,7 +22,6 @@ mongoClient.connect(mongoUrl, function(err, db) {
router.get('/:resource_id', function(req, res, next) {
var _id = req.params.resource_id;
mongoClient.connect(mongoUrl, function(err, db) {
if(err!=null){
......@@ -32,6 +33,7 @@ router.get('/:resource_id', function(req, res, next) {
var collection = db.collection('resources');
var _id = new objectID(req.params.resource_id);
collection.find({"_id":_id}).limit(1).next(function(err, doc){
if(err!=null){
......@@ -43,7 +45,7 @@ router.get('/:resource_id', function(req, res, next) {
if(doc==undefined){
res.sendStatus(400);
res.sendStatus(404);
}else{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment