Renamed advanced-reactor to advancedReactor to prevent errors due to hyphen in name
This commit is contained in:
26
advancedReactor.js
Normal file
26
advancedReactor.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const nameOfNode = "advancedReactor"; // name of the node, should match file name and node type in Node-RED
|
||||
const nodeClass = require('./src/nodeClass.js'); // node class
|
||||
const { MenuManager } = require('generalFunctions');
|
||||
|
||||
|
||||
module.exports = function (RED) {
|
||||
// Register the node type
|
||||
RED.nodes.registerType(nameOfNode, function (config) {
|
||||
// Initialize the Node-RED node first
|
||||
RED.nodes.createNode(this, config);
|
||||
// Then create your custom class and attach it
|
||||
this.nodeClass = new nodeClass(config, RED, this, nameOfNode);
|
||||
});
|
||||
|
||||
const menuMgr = new MenuManager();
|
||||
|
||||
// Serve /advancedReactor/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}`);
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user