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

Tidy up /flows api responses

This commit is contained in:
Nick O'Leary 2016-10-12 10:24:10 +01:00
parent 05cbba9a35
commit 5344949c71

View File

@ -33,8 +33,8 @@ module.exports = {
log.audit({event: "flows.get",version:"v2"},req);
res.json(redNodes.getFlows());
} else {
log.audit({event: "flows.get",version:version,error:"bad_api_version"},req);
res.status(400).json({error:"bad_api_version"});
log.audit({event: "flows.get",version:version,error:"invalid_api_version"},req);
res.status(400).json({code:"invalid_api_version", message:"Invalid API Version requested"});
}
},
post: function(req,res) {
@ -58,12 +58,12 @@ module.exports = {
var currentVersion = redNodes.getFlows().rev;
if (currentVersion !== flows.rev) {
//TODO: log warning
return res.status(409).json({error:"version_mismatch"});
return res.status(409).json({code:"version_mismatch"});
}
}
} else if (version !== 'v1') {
log.audit({event: "flows.set",version:version,error:"bad_api_version"},req);
return res.status(400).json({error:"bad_api_version"});
log.audit({event: "flows.set",version:version,error:"invalid_api_version"},req);
res.status(400).json({code:"invalid_api_version", message:"Invalid API Version requested"});
}
redNodes.setFlows(flowConfig,deploymentType).then(function(flowId) {
if (version === "v1") {