I would like to intercept the POST /flows API request (at runtime) and add additional logic before its sending a respond to the editor.
After looking at the docs I wasn't able to find hooks or other options to active this behavior.
Currently the only way I was able to detect the request is by accessing the RED.server (NodeRed node http server) object like this:
RED.server.on("request", (req, res) => { ... })
But I'm unable to make it wait for my logic to finish.
I Found a way to intercept the setFlow action although very hacky
import RED from 'node-red';
...
const setFlowOrg: Function = (RED as any).runtime.flows.setFlows;
const flowThis: any = (RED as any).runtime.flows;
(RED as any).runtime.flows.setFlows = async (...data: any[]) => {
console.log("before.setFlows");
const res = await setFlowOrg.apply(flowThis, data);
console.log("after.setFlows");
return res;
}