Global ContextHolder

I'm using Hono on cloudflare workers and my handle functions look like:
async handle(ctx: Context<Env>) { .. }
async handle(ctx: Context<Env>) { .. }
and I'm then passing that ctx that to other method calls in multiple layers. which feels quite cumbersome. is it possible to create some global ContextHolder where I can set and get the ctx from? Like a request-scoped holder... I wonder how others do this?
2 Replies
Hard@Work
Hard@Work4mo ago
Cloudflare Docs
AsyncLocalStorage | Cloudflare Workers docs
Cloudflare Workers provides an implementation of a subset of the Node.js AsyncLocalStorage API for creating in-memory stores that remain coherent through asynchronous operations.
Marcel Overdijk
Marcel OverdijkOP4mo ago
Ah cool . Did not now AsyncLocalStorage was supported 👍
Want results from more Discord servers?
Add your server