-
Notifications
You must be signed in to change notification settings - Fork 23
Labels
Description
Is your feature request related to a problem? Please describe.
As a user, I would like to be able to execute scripts that modify the request.
Describe the solution you'd like
- In the frontend, a new tab that allows writing JS code. There should be autocompletion for the trufos scripting API in the Monaco editor.
- In the backend:
- a scripting API that allows modification of the request (and body) before sending it
- a separate JS file next to the
request.jsonfile - handling and execution of the JS file before sending the request
- A scripting engine to run the script isolated from the actual app code
- Use
node:child_process.fork()to start a new node process with the user script as code - Inject the public calls to the app into the script (
rufos.requestobject for request scripts andrufos.responsefor response scripts. Variable management, e.g.trufos.variables.set("myVar", "value")
- Use
- The request should only be sent after the script ran successfully (if there's a request script)
Describe alternatives you've considered
- A scripting engine to run the script isolated from the actual app code
- Use
node:child_process.fork()to start a runner script that translates calls to global variables and forwards them to the main process - Use
node:vmto load the user script
- Use
This guarantees working globals and isolated script running. Might also speed up script running since the child process can live permanently and start multiple VMs (one per script) whenever it should run.
Additional context
This is a large feature. The exact subtasks need to be planned and written as issues.
Reactions are currently unavailable