Open GregBrimble opened 1 month ago
Hi @GregBrimble
The following works well.
import { Hono } from 'hono'
import { WorkerEntrypoint } from 'cloudflare:workers'
const app = new Hono()
app.get('/', (c) => {
return c.text('Hello Hono!')
})
export default class extends WorkerEntrypoint {
fetch = app.fetch
}
Do you think about this? I think this is the smartest way.
Unfortunately not. WorkerEntrypoint
's fetch
signature is just fetch(request: Request)
. It doesn't come with the env
or ctx
parameters that app.fetch
expects. These are instead available on the WorkerEntrypoint
instance, this
.
@GregBrimble Ahh, understood. I’ll consider it.
@yusukebe and how you call the method or endpoint in the other worker?
What is the feature you are proposing?
Hey! Love that I can just do
export default { fetch: app.fetch }
for ESM Workers. What's the ergonomic equivalent forWorkerEntrypoint
s?I currently define them like:
Is there some magic we'd consider adding so I can just do this?