Aligns the entry-file naming with the folder-name convention from
.claude/rules/node-architecture.md / superproject CLAUDE.md.
NON-BREAKING: the Node-RED type id stays lowercase
(`RED.nodes.registerType('dashboardapi', ...)`) so every deployed flow
that references this node continues to load. Only the file paths
change. Admin endpoints `/dashboardapi/menu.js` and
`/dashboardapi/configData.js` are unaffected — they follow the type
id, not the filename.
Updated:
- package.json `main` + `node-red.nodes` value
- test/basic/structure-module-load.basic.test.js require path
- CLAUDE.md: legacy-drift warning replaced with a note explaining the
type-id preservation strategy
Same approach recommended for the remaining two legacy renames (mgc,
vgc); the superproject CLAUDE.md drift table now spells that out.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const nameOfNode = 'dashboardapi';
|
|
const nodeClass = require('./src/nodeClass.js');
|
|
const { MenuManager } = require('generalFunctions');
|
|
|
|
module.exports = function (RED) {
|
|
RED.nodes.registerType(nameOfNode, function (config) {
|
|
RED.nodes.createNode(this, config);
|
|
this.nodeClass = new nodeClass(config, RED, this, nameOfNode);
|
|
});
|
|
|
|
const menuMgr = new MenuManager();
|
|
|
|
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}`);
|
|
}
|
|
});
|
|
|
|
// Provide config metadata for the editor (local, no dependency on generalFunctions configs).
|
|
RED.httpAdmin.get(`/${nameOfNode}/configData.js`, (req, res) => {
|
|
try {
|
|
const configPath = path.join(__dirname, 'dependencies', 'dashboardapi', 'dashboardapiConfig.json');
|
|
const json = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
const script = `
|
|
window.EVOLV = window.EVOLV || {};
|
|
window.EVOLV.nodes = window.EVOLV.nodes || {};
|
|
window.EVOLV.nodes.${nameOfNode} = window.EVOLV.nodes.${nameOfNode} || {};
|
|
window.EVOLV.nodes.${nameOfNode}.config = ${JSON.stringify(json, null, 2)};
|
|
`;
|
|
res.type('application/javascript').send(script);
|
|
} catch (err) {
|
|
res.status(500).send(`// Error generating configData: ${err.message}`);
|
|
}
|
|
});
|
|
};
|