Integrating JsRuntime properly with Axum #20957
Unanswered
Toasterson
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Here's a simple example of creating a realm using the deno_core crate:
Remember that when using realms, each realm is essentially an isolated JavaScript environment. Changes made in one realm do not affect other realms. You can execute code in a realm and then clean it up when you're done. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello all.
I am using deno_core as a Javascript runtime for me to make a webhook server. I am making the Webserver part in axum and at the moment I make a JsRuntime in every handler, that gets called. I tried to do the more resonable shared state approach but many things inside the JsRuntime do not implement sync so I cant add it to the shared state.
My current handler looks like this:
Does it make sense to run the JsRuntime::new() calls globally once or is that ok inside the handler like in the example? If it is better to run global, is it easy to call create_realm to create a realm? Is there a realm example, that cleans up after the functions has ended?
Beta Was this translation helpful? Give feedback.
All reactions