1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Replaced delete response with 204

This commit is contained in:
Anna Thomas 2014-11-21 11:25:51 +00:00
parent 56cb985de9
commit 70f101497d
3 changed files with 11 additions and 18 deletions

View File

@ -54,7 +54,7 @@ function init(adminApp) {
adminApp.get("/nodes/:mod",nodes.getModule);
adminApp.put("/nodes/:mod",nodes.putModule);
adminApp.delete("/nodes/:id",nodes.delete);
adminApp.delete("/nodes/:mod",nodes.delete);
adminApp.get("/nodes/:mod/:set",nodes.getSet);
adminApp.put("/nodes/:mod/:set",nodes.putSet);

View File

@ -70,25 +70,19 @@ module.exports = {
res.send(400,new Error("Settings unavailable").toString());
return;
}
var id = req.params.id;
var removedNodes = [];
var mod = req.params.mod;
try {
var node = redNodes.getNodeInfo(id);
var promise = null;
if (!node) {
var module = redNodes.getNodeModuleInfo(id);
if (!module) {
res.send(404);
return;
} else {
promise = server.uninstallModule(id);
}
var module = redNodes.getNodeModuleInfo(mod);
if (!module) {
res.send(404);
return;
} else {
promise = when.resolve([redNodes.removeNode(id)]).then(server.reportRemovedModules);
promise = server.uninstallModule(mod);
}
promise.then(function(removedNodes) {
res.json(removedNodes);
promise.then(function() {
res.send(204);
}).otherwise(function(err) {
res.send(400,err.toString());
});

View File

@ -329,7 +329,7 @@ describe("nodes api", function() {
});
describe('by module', function() {
it('uninstalls the module and returns node info', function(done) {
it('uninstalls the module', function(done) {
var settingsAvailable = sinon.stub(settings,'available', function() {
return true;
});
@ -345,7 +345,7 @@ describe("nodes api", function() {
request(app)
.del('/nodes/foo')
.expect(200)
.expect(204)
.end(function(err,res) {
settingsAvailable.restore();
getNodeInfo.restore();
@ -354,7 +354,6 @@ describe("nodes api", function() {
if (err) {
throw err;
}
res.body.should.have.property("id","123");
done();
});
});