Skip to content

Commit

Permalink
feat: Support for asynchronous getLoadContext (#22)
Browse files Browse the repository at this point in the history
* Support for asynchronous `getLoadContext`

* check `remixContext` is promise or not

---------

Co-authored-by: Yusuke Wada <[email protected]>
  • Loading branch information
ogadra and yusukebe authored Nov 17, 2024
1 parent 12ae2e1 commit b0e39e2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/remix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ export type GetLoadContext = (args: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
cloudflare: any
}
}) => AppLoadContext
}) => AppLoadContext | Promise<AppLoadContext>

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const defaultGetLoadContext = ({ context }: any) => {
export const defaultGetLoadContext = ({ context }: any): AppLoadContext => {
return {
...context,
}
Expand Down

0 comments on commit b0e39e2

Please sign in to comment.