Basic EVOLV setup
This commit is contained in:
@@ -1,6 +1,26 @@
|
||||
const nameOfNode = "liquidFlowHandler";
|
||||
const nodeClass = require('./src/nodeClass.js');
|
||||
const { MenuManager } = require('generalFunctions');
|
||||
|
||||
module.exports = function(RED) {
|
||||
function liquidFlowHandler(config) {
|
||||
RED.nodes.createNode(this, config);
|
||||
// 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}`);
|
||||
}
|
||||
RED.nodes.registerType("liquidFlowHandler", liquidFlowHandler);
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user