-
Notifications
You must be signed in to change notification settings - Fork 67
React Router Hono Server v2 #11
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
Merged
+333
−833
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,4 @@ side-effects-cache=false | |
| save-exact=true | ||
| audit=false | ||
| fund=false | ||
| progress=false | ||
| progress=false | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import type { Context } from "hono" | ||
| import { i18next } from "remix-hono/i18next" | ||
| import { getClientEnv, initEnv } from "~/env.server" | ||
|
|
||
| // Setup the .env vars | ||
| const env = initEnv() | ||
|
|
||
| export const getLoadContext = async (c: Context) => { | ||
| // get the locale from the context | ||
| const locale = i18next.getLocale(c) | ||
| // get t function for the default namespace | ||
| const t = await i18next.getFixedT(c) | ||
|
|
||
| const clientEnv = getClientEnv() | ||
| return { | ||
| lang: locale, | ||
| t, | ||
| env, | ||
| clientEnv, | ||
| // We do not add this to AppLoadContext type because it's not needed in the loaders, but it's used above to handle requests | ||
| body: c.body, | ||
| } | ||
| } | ||
|
|
||
| interface LoadContext extends Awaited<ReturnType<typeof getLoadContext>> {} | ||
|
|
||
| /** | ||
| * Declare our loaders and actions context type | ||
| */ | ||
| declare module "react-router" { | ||
| interface AppLoadContext extends Omit<LoadContext, "body"> {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { createHonoServer } from "react-router-hono-server/node" | ||
| import { i18next } from "remix-hono/i18next" | ||
| import i18nextOpts from "../localization/i18n.server" | ||
| import { getLoadContext } from "./context" | ||
|
|
||
| export default await createHonoServer({ | ||
| configure(server) { | ||
| server.use("*", i18next(i18nextOpts)) | ||
| }, | ||
| defaultLogger: false, | ||
| getLoadContext, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| { | ||
| "$schema": "https://unpkg.com/knip@5/schema.json", | ||
| "entry": ["scripts/*.{ts,js}", "app/routes.ts","vite.config.ts"], | ||
| "entry": ["scripts/*.{ts,js}", "app/routes.ts","vite.config.ts", "app/server/*.ts"], | ||
| "remix": true, | ||
| "project": ["**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}", "vite.config.ts"], | ||
| "ignore": ["app/library/icon/icons/types.ts"] | ||
| "ignore": ["app/library/icon/icons/types.ts", "app/server"] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.