diff --git a/benchmarks/handle-event/index.js b/benchmarks/handle-event/index.js index bb417885..772efe46 100644 --- a/benchmarks/handle-event/index.js +++ b/benchmarks/handle-event/index.js @@ -114,7 +114,7 @@ makeEdgeEnv() const event = new FetchEvent('fetch', { request }) const fn = async () => { - let res = await hono.handleEvent(event) + let res = await hono.fetch(event.request) console.log(await res.text()) res = await ittyRouter.handle(event.request) console.log(await res.text()) @@ -129,7 +129,7 @@ const suite = new Benchmark.Suite() suite .add('Hono', async () => { - await hono.handleEvent(event) + await hono.fetch(event.request) }) .add('itty-router', async () => { await ittyRouter.handle(event.request) diff --git a/deno_dist/hono-base.ts b/deno_dist/hono-base.ts index 5965ab41..2ed34f89 100644 --- a/deno_dist/hono-base.ts +++ b/deno_dist/hono-base.ts @@ -351,6 +351,11 @@ class Hono extends d })() } + /** + * @deprecate + * `app.handleEvent()` will be removed in v4. + * Use `app.fetch()` instead of `app.handleEvent()`. + */ handleEvent = (event: FetchEventLike) => { return this.dispatch(event.request, event, undefined, event.request.method) } @@ -375,8 +380,8 @@ class Hono extends d fire = () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - addEventListener('fetch', (event: FetchEvent): void => { - void event.respondWith(this.handleEvent(event)) + addEventListener('fetch', (event: FetchEventLike): void => { + event.respondWith(this.dispatch(event.request, event, undefined, event.request.method)) }) } } diff --git a/src/hono-base.ts b/src/hono-base.ts index 882943d9..378f5846 100644 --- a/src/hono-base.ts +++ b/src/hono-base.ts @@ -351,6 +351,11 @@ class Hono extends d })() } + /** + * @deprecate + * `app.handleEvent()` will be removed in v4. + * Use `app.fetch()` instead of `app.handleEvent()`. + */ handleEvent = (event: FetchEventLike) => { return this.dispatch(event.request, event, undefined, event.request.method) } @@ -375,8 +380,8 @@ class Hono extends d fire = () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - addEventListener('fetch', (event: FetchEvent): void => { - void event.respondWith(this.handleEvent(event)) + addEventListener('fetch', (event: FetchEventLike): void => { + event.respondWith(this.dispatch(event.request, event, undefined, event.request.method)) }) } }