-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: pass hono's context in getLoadContext
#24
Conversation
@@ -4,11 +4,12 @@ import { useLoaderData } from '@remix-run/react' | |||
export const loader = (args: LoaderFunctionArgs) => { | |||
const extra = args.context.extra | |||
const cloudflare = args.context.cloudflare | |||
return { cloudflare, extra } | |||
const myVarInVariables = args.context.hono.context.get('MY_VAR_IN_VARIABLES') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This args.context.hono.context
seems verbose, but I don't have a good idea for the naming.
@yusukebe |
@ogadra Thank you! @predaytor What do you think of this? If okay, please review it. |
@yusukebe would be great! So far I have used the Context Storage middleware to access the Hono context: import { getContext as getContextStorage } from 'hono/context-storage';
import { type ContextEnv } from './server';
export function getContext() {
return getContextStorage<ContextEnv>();
}
///
export async function getLoadContext({ context, request }: GetLoadContextArgs) {
const c = getContext();
c.var.rateLimit
return {
...context,
};
} |
Thanks. I also thought the Context Storage middleware could fit this use case. But the feature in this PR will be helpful! |
Seems to be good! I'll merge this now. If you have any requests to change, please feel free to create your PR. |
Fixes #23