From 150bfd17bc149c5730e62f80ae1ead6bf35b93ba Mon Sep 17 00:00:00 2001 From: isucon server <61941819+ogadra@users.noreply.github.com> Date: Fri, 15 Nov 2024 20:58:35 +0900 Subject: [PATCH 1/2] Support for asynchronous `getLoadContext` --- src/remix.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/remix.ts b/src/remix.ts index 22902a3..712df99 100644 --- a/src/remix.ts +++ b/src/remix.ts @@ -8,7 +8,7 @@ export type GetLoadContext = (args: { // eslint-disable-next-line @typescript-eslint/no-explicit-any cloudflare: any } -}) => AppLoadContext +}) => AppLoadContext | Promise // eslint-disable-next-line @typescript-eslint/no-explicit-any export const defaultGetLoadContext = ({ context }: any) => { From 37cda75261ba7f076b1fc1d29dae9c55c1609c05 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Sun, 17 Nov 2024 06:08:30 +0900 Subject: [PATCH 2/2] check `remixContext` is promise or not --- src/dev.ts | 2 +- src/remix.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dev.ts b/src/dev.ts index 45173b1..8323d73 100644 --- a/src/dev.ts +++ b/src/dev.ts @@ -23,7 +23,7 @@ export const handle = (userApp?: Hono, options?: Options) => { const args = createGetLoadContextArgs(c) const remixContext = getLoadContext(args) - return handler(c.req.raw, remixContext) + return handler(c.req.raw, remixContext instanceof Promise ? await remixContext : remixContext) }) return app diff --git a/src/remix.ts b/src/remix.ts index 712df99..6d9ffb5 100644 --- a/src/remix.ts +++ b/src/remix.ts @@ -11,7 +11,7 @@ export type GetLoadContext = (args: { }) => AppLoadContext | Promise // eslint-disable-next-line @typescript-eslint/no-explicit-any -export const defaultGetLoadContext = ({ context }: any) => { +export const defaultGetLoadContext = ({ context }: any): AppLoadContext => { return { ...context, }