Rename getRootRouter to getRootApp for clarity in HTTP node handling

This commit is contained in:
Debadutta Panda 2025-02-05 11:33:43 +05:30
parent 5d07c8b215
commit 22e9d3e890

View File

@ -71,11 +71,11 @@ module.exports = function(RED) {
});
}
function getRootRouter(app) {
function getRootApp(app) {
if (typeof app.parent === 'undefined') {
return app;
}
return getRootRouter(app.parent)
return getRootApp(app.parent)
}
function createRouteId(req) {
@ -83,7 +83,7 @@ module.exports = function(RED) {
return `${method}:${url}`;
}
var rootApp = getRootRouter(RED.httpNode)
var rootApp = getRootApp(RED.httpNode)
// Check if middleware already exists
var isMiddlewarePresent = rootApp._router.stack.some(layer => layer.name === 'setupRawBodyCapture')
@ -352,10 +352,10 @@ module.exports = function(RED) {
RED.httpNode.delete(this.url, cookieParser(), httpMiddleware, corsHandler, metricsHandler, jsonParser, urlencParser, rawBodyParser, this.callback, this.errorHandler);
}
// unique id for httpInNodeSettings based on method name and url path
// unique id for httpInNode based on method name and url path
var httpInNodeId = createRouteId({url: this.url, method: this.method})
// get httpInNodeSettings from RED.httpNode
// get httpInNode from RED.httpNode
var httpInNodes = rootApp.get('httpInNodes')
// Add httpInNode to RED.httpNode