Skip to content

Commit b0e39e2

Browse files
ogadrayusukebe
andauthored
feat: Support for asynchronous getLoadContext (#22)
* Support for asynchronous `getLoadContext` * check `remixContext` is promise or not --------- Co-authored-by: Yusuke Wada <yusuke@kamawada.com>
1 parent 12ae2e1 commit b0e39e2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const handle = (userApp?: Hono, options?: Options) => {
2323
const args = createGetLoadContextArgs(c)
2424

2525
const remixContext = getLoadContext(args)
26-
return handler(c.req.raw, remixContext)
26+
return handler(c.req.raw, remixContext instanceof Promise ? await remixContext : remixContext)
2727
})
2828

2929
return app

src/remix.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ export type GetLoadContext = (args: {
88
// eslint-disable-next-line @typescript-eslint/no-explicit-any
99
cloudflare: any
1010
}
11-
}) => AppLoadContext
11+
}) => AppLoadContext | Promise<AppLoadContext>
1212

1313
// eslint-disable-next-line @typescript-eslint/no-explicit-any
14-
export const defaultGetLoadContext = ({ context }: any) => {
14+
export const defaultGetLoadContext = ({ context }: any): AppLoadContext => {
1515
return {
1616
...context,
1717
}

0 commit comments

Comments
 (0)