From 6db1cc63d51717f90a152b5ab60712c2875932ee Mon Sep 17 00:00:00 2001 From: Taku Amano Date: Sat, 11 May 2024 23:37:23 +0900 Subject: [PATCH] feat(hono-base): tweaks `fetch` signature for better compatibility with `deno serve` (#2661) --- deno_dist/hono-base.ts | 8 ++++++-- src/hono-base.ts | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/deno_dist/hono-base.ts b/deno_dist/hono-base.ts index 2ddaff9a5..b49a6fc33 100644 --- a/deno_dist/hono-base.ts +++ b/deno_dist/hono-base.ts @@ -371,8 +371,12 @@ class Hono< * `.fetch()` will be entry point of your app. * @see https://hono.dev/api/hono#fetch */ - fetch = (request: Request, Env?: E['Bindings'] | {}, executionCtx?: ExecutionContext) => { - return this.dispatch(request, executionCtx, Env, request.method) + fetch: ( + request: Request, + Env?: E['Bindings'] | {}, + executionCtx?: ExecutionContext + ) => Response | Promise = (request, ...rest) => { + return this.dispatch(request, rest[1], rest[0], request.method) } /** diff --git a/src/hono-base.ts b/src/hono-base.ts index 6bd44efd8..cb4092e38 100644 --- a/src/hono-base.ts +++ b/src/hono-base.ts @@ -371,8 +371,12 @@ class Hono< * `.fetch()` will be entry point of your app. * @see https://hono.dev/api/hono#fetch */ - fetch = (request: Request, Env?: E['Bindings'] | {}, executionCtx?: ExecutionContext) => { - return this.dispatch(request, executionCtx, Env, request.method) + fetch: ( + request: Request, + Env?: E['Bindings'] | {}, + executionCtx?: ExecutionContext + ) => Response | Promise = (request, ...rest) => { + return this.dispatch(request, rest[1], rest[0], request.method) } /**