mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Posting to /flows should block until successfully saved, or fail
Mentioned in #76
This commit is contained in:
parent
ff8db09fd9
commit
0aa17662f5
@ -49,14 +49,20 @@ function createServer(_server,_settings) {
|
||||
fullBody += chunk.toString();
|
||||
});
|
||||
req.on('end', function() {
|
||||
res.writeHead(204, {'Content-Type': 'text/plain'});
|
||||
res.end();
|
||||
var flows = JSON.parse(fullBody);
|
||||
storage.saveFlows(flows).then(function() {
|
||||
redNodes.setConfig(flows);
|
||||
}).otherwise(function(err) {
|
||||
try {
|
||||
var flows = JSON.parse(fullBody);
|
||||
storage.saveFlows(flows).then(function() {
|
||||
res.writeHead(204, {'Content-Type': 'text/plain'});
|
||||
res.end();
|
||||
redNodes.setConfig(flows);
|
||||
}).otherwise(function(err) {
|
||||
util.log("[red] Error saving flows : "+err);
|
||||
res.send(500, err.message);
|
||||
});
|
||||
} catch(err) {
|
||||
util.log("[red] Error saving flows : "+err);
|
||||
});
|
||||
res.send(400, "Invalid flow");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user