Binding outside of the fetch handler?

I got an application I'm porting to cloudflare workers. It has domain services that are instantiated at app start. These services hide underlying storage and other implementation details from the application (ie the API). When an API call comes it, it parses the request and passes it on to a domain service which the handler has a reference to (got injected when the route was set up). How would I replicate this on Workers where the bindings are given to the fetch handler? Would you bootstrap the app from scratch (ie, creating all domain services, creating the Hono routes that references these services, ...) on every request and then dispatch the request to the hono app?
No description
1 Reply
jrydberg
jrydbergOP2mo ago
Can you do save a ref to the env without the worker breaking?
Want results from more Discord servers?
Add your server