im trying to convert nodejs express web application to node-red .
My understanding till now is it that node-red in this case work juste like any other middelware in the nodejs host but with some differences :
. if i have the same http url that start with the node-red httpNodeRoot in both nodejs and Node-red editor the request (express nodejs server) will ignore the nodejs app.use(url, middelware) and go directelly to Node-red... and if i remove the http node that use the that same url then the request will consider this middeware in nodejs like any other nodejs middelware even if it start with the HttpNodeRoot this prevent me from using any middelware (router, controller...) or pass data through req from nodejs To node-red ....
. There is some kind of redirection and i guess it start a new and different request so all the data in the request that reach nodejs become a msg..paylod.... and does not go through other nodejs middeware chain... node-red middelware work in isolation....
.So Node-red is a middelware but does not belong to nodejs express chain of middelwares or scope so no data can be exchanged i cant use next() also...
the good thing is that i can require all the modules installed with npm in Node-red
but i cant require the javascripts files with module.require because there no files to require...so as a work around i used a function node and i used instant invoqued function to have the same result and store the returned function in req.property...
My question is how can i use nodejs midellwares like router js files like controllers files in node-Red without having to convert all my nodejs code to IIF functions if only i can use any nodejs middeware or pass data through req......
if we can require modules from Nodejs i should be able to require other files.js because they are considered as modules in nodejs....
i was able to use the envirenement variable without adding them to settings.js
there is a npm module called dotEnv that convert the config.env files to envirement variable and with process.env.VARIABLE it work because global.env didnt work for me ... this why i want to have access to nodejs because he can do a lot for Node-red