Reputation: 3
I am working on a Node.js app, and am currently debugging it, and I was wondering if it is possible to have a repl running that could change variables defined in the node application itself, not in the REPL's context, is this possible?
For example, i could enter var app = express()
into the REPL, and it would also set the variable in the server itself.
If so, how would I go about implementing it and making it secure?
Upvotes: 0
Views: 346
Reputation: 1401
You cannot directly access the run-time of another javascript interpreter, so if you would like to interact with your running application, you have a few options:
Look into the REPL module for adding a REPL inside of your application (your app could start, then show a REPL), and then the VM module for specifying the exact context you are operating on inside the REPL.
Securing it is another thing entirely.
Set up some interaction model with your application, such as a socket and write both client and server independently. forever is an example of how this interaction works, but it would need to be adjusted for remote javascript execution.
Upvotes: 1