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:
parent
56cb985de9
commit
70f101497d
@ -54,7 +54,7 @@ function init(adminApp) {
|
|||||||
|
|
||||||
adminApp.get("/nodes/:mod",nodes.getModule);
|
adminApp.get("/nodes/:mod",nodes.getModule);
|
||||||
adminApp.put("/nodes/:mod",nodes.putModule);
|
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.get("/nodes/:mod/:set",nodes.getSet);
|
||||||
adminApp.put("/nodes/:mod/:set",nodes.putSet);
|
adminApp.put("/nodes/:mod/:set",nodes.putSet);
|
||||||
|
@ -70,25 +70,19 @@ module.exports = {
|
|||||||
res.send(400,new Error("Settings unavailable").toString());
|
res.send(400,new Error("Settings unavailable").toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var id = req.params.id;
|
var mod = req.params.mod;
|
||||||
var removedNodes = [];
|
|
||||||
try {
|
try {
|
||||||
var node = redNodes.getNodeInfo(id);
|
|
||||||
var promise = null;
|
var promise = null;
|
||||||
if (!node) {
|
var module = redNodes.getNodeModuleInfo(mod);
|
||||||
var module = redNodes.getNodeModuleInfo(id);
|
if (!module) {
|
||||||
if (!module) {
|
res.send(404);
|
||||||
res.send(404);
|
return;
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
promise = server.uninstallModule(id);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
promise = when.resolve([redNodes.removeNode(id)]).then(server.reportRemovedModules);
|
promise = server.uninstallModule(mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
promise.then(function(removedNodes) {
|
promise.then(function() {
|
||||||
res.json(removedNodes);
|
res.send(204);
|
||||||
}).otherwise(function(err) {
|
}).otherwise(function(err) {
|
||||||
res.send(400,err.toString());
|
res.send(400,err.toString());
|
||||||
});
|
});
|
||||||
|
@ -329,7 +329,7 @@ describe("nodes api", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('by module', 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() {
|
var settingsAvailable = sinon.stub(settings,'available', function() {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@ -345,7 +345,7 @@ describe("nodes api", function() {
|
|||||||
|
|
||||||
request(app)
|
request(app)
|
||||||
.del('/nodes/foo')
|
.del('/nodes/foo')
|
||||||
.expect(200)
|
.expect(204)
|
||||||
.end(function(err,res) {
|
.end(function(err,res) {
|
||||||
settingsAvailable.restore();
|
settingsAvailable.restore();
|
||||||
getNodeInfo.restore();
|
getNodeInfo.restore();
|
||||||
@ -354,7 +354,6 @@ describe("nodes api", function() {
|
|||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
res.body.should.have.property("id","123");
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user