mirror of
https://github.com/honojs/hono.git
synced 2024-11-21 18:18:57 +01:00
refactor(app): add "deprecate message" for app.handleEvent()
(#1298)
* refactor(app): add "deprecate message" for `app.handleEvent()` * denoify
This commit is contained in:
parent
4a3c5834de
commit
85f8ab663f
@ -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)
|
||||
|
@ -351,6 +351,11 @@ class Hono<E extends Env = Env, S = {}, BasePath extends string = '/'> 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<E extends Env = Env, S = {}, BasePath extends string = '/'> 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))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -351,6 +351,11 @@ class Hono<E extends Env = Env, S = {}, BasePath extends string = '/'> 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<E extends Env = Env, S = {}, BasePath extends string = '/'> 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))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user