Hello Everyone,
We selected Node-RED as a workflow designer and manager to embed in a web application. It's a potent and flexible tool, and I enjoy working on it.
We're embedding Node-RED in an express app that will expose the editor and the admin API to be consumed by other APIs on a separate express instance. The flow definitions, contexts, sessions and credentials will be saved to a database using a set of APIs. So far, I have managed to save everything by integrating a self-made storage module.
One of the issues I encountered was that I could not intercept the deletion of a workflow. I want to ensure that the stored flow definitions match what the users view in the editor. The saveFlows method in the storage module only passes the updated/new definitions as a parameter, and I'm unable to identify what has been deleted. Looking at the documentation I saw that I can subscribe to a flows:removed event. I tried, but it's not firing (among other events I tried, like flows:change and deploy).
RED.init(super._server, redSettings);
super.expressApp.use(redSettings.httpAdminRoot, RED.httpAdmin);
super.expressApp.use(redSettings.httpNodeRoot, RED.httpNode);
RED.events.on('flows:remove', (node) => {
console.log(node);
});
RED.events.on('flows:change', (node) => {
console.log('CHANGED!!!!');
});
RED.events.on('deploy', (node) => {
console.log('deploy');
});
As far as I understand, there are two types of events in Node-RED: runtime events and editor events. The events I'm trying to subscribe to are editor-related events, and for those, I need to integrate the @node-red/editor-api.
I got stuck there: I can't find an example, tutorial or documentation that will guide me in subscribing to these events. Also, GitHub Copilot seems confused when dealing with this topic
Does someone have some resources or documentation to share, or can give me a brief heads-up on where to look to intercept those events?
Version of Node.JS: 20.11.0
Version of Node-RED: 4.0.5
Thanks, and Happy Coding.
Edoardo.