Files
liquidFlowHandler/liquidFlowHandler.js
2025-07-23 14:46:03 +02:00

27 lines
827 B
JavaScript

const nameOfNode = "liquidFlowHandler";
const nodeClass = require('./src/nodeClass.js');
const { MenuManager } = require('generalFunctions');
module.exports = function(RED) {
// 1) Register the node type and delegate to your class
RED.nodes.registerType(nameOfNode, function(config) {
RED.nodes.createNode(this, config);
this.nodeClass = new nodeClass(config, RED, this, nameOfNode);
});
// 2) Setup the dynamic menu endpoint
const menuMgr = new MenuManager();
// Serve /liquidFlowHandler/menu.js
RED.httpAdmin.get(`/${nameOfNode}/menu.js`, (req, res) => {
try {
const script = menuMgr.createEndpoint(nameOfNode, ['logger']);
res.type('application/javascript').send(script);
} catch (err) {
res.status(500).send(`// Error generating menu: ${err.message}`);
}
});
};