Replies: 2 comments 1 reply
-
An equivalent of Hono In the mean time, you can perhaps try to give an object with a function as your middleware parameters: interface Arg {
getEnv: () => Record<string, string>
}
const contextMiddleware = ((arg) => (request, ctx, runtime) => {
const env = arg.getEnv();
// ...
}) satisfies Get<[Arg], UniversalMiddleware>; |
Beta Was this translation helpful? Give feedback.
1 reply
-
env helper available in |
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
-
Example use case: configure an API client from environment variables.
For instance, Hono has an
env()
adapter that makes the environment variables in Cloudflare accessible to a request handler/middleware via the context object.createMiddleware()/createHandler() do accept parameters that can be passed to the middleware/handler, but expect them to be known at build time (example from the docs). In my use case, I'd like to pass in API client details from the environment, which lives in the context object in Hono, which is only known at runtime.
Beta Was this translation helpful? Give feedback.
All reactions