fake-api-server
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.7.1 | ||
// Generated by CoffeeScript 1.8.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ module.exports = { |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.7.1 | ||
// Generated by CoffeeScript 1.8.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var Resource; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.7.1 | ||
// Generated by CoffeeScript 1.8.0 | ||
(function() { | ||
@@ -30,2 +30,5 @@ var Server, bodyParser, express; | ||
return _this.find(req.params.resource, function(resource) { | ||
if (!resource) { | ||
return res.send(404); | ||
} | ||
return res.send(resource.all()); | ||
@@ -39,8 +42,10 @@ }); | ||
var data; | ||
if (data = resource.find(req.params.id)) { | ||
return res.send(data); | ||
} else { | ||
if (!resource) { | ||
return res.send(404); | ||
} | ||
if (!(data = resource.find(req.params.id))) { | ||
res.statusCode = 404; | ||
return res.send("No " + (resource.name()) + " with id " + req.params.id); | ||
} | ||
return res.send(data); | ||
}); | ||
@@ -53,2 +58,5 @@ }; | ||
var data; | ||
if (!resource) { | ||
return res.send(404); | ||
} | ||
data = req.body; | ||
@@ -63,2 +71,5 @@ resource.add(data); | ||
return _this.find(req.params.resource, function(resource) { | ||
if (!resource) { | ||
return res.send(404); | ||
} | ||
if (resource.update(req.params.id, req.body)) { | ||
@@ -76,2 +87,5 @@ return res.send(200); | ||
return _this.find(req.params.resource, function(resource) { | ||
if (!resource) { | ||
return res.send(404); | ||
} | ||
if (resource.remove(req.params.id)) { | ||
@@ -97,3 +111,3 @@ return res.send(200); | ||
} | ||
return res.send(404); | ||
return cb(null); | ||
}; | ||
@@ -100,0 +114,0 @@ |
{ | ||
"name": "fake-api-server", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "Andrew Couch <fake-api-server@andrewcou.ch>", | ||
@@ -10,2 +10,5 @@ "description": "A simple, easy mock REST API server.", | ||
}, | ||
"scripts": { | ||
"test": "make && mocha" | ||
}, | ||
"main": "./lib/index", | ||
@@ -24,4 +27,5 @@ "license": "MIT", | ||
"chai": "~1.9.1", | ||
"mocha": "~1.18.2" | ||
"mocha": "~1.18.2", | ||
"coffee-script": "~1.8.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
27652
176
3
15
238