|
1 | 1 | import { PassThrough } from "node:stream" |
2 | 2 | import { createReadableStreamFromReadable } from "@react-router/node" |
3 | | -import type { Context } from "hono" |
4 | 3 | import { createInstance } from "i18next" |
5 | 4 | import { isbot } from "isbot" |
6 | 5 | import { renderToPipeableStream } from "react-dom/server" |
7 | 6 | import { I18nextProvider, initReactI18next } from "react-i18next" |
8 | 7 | import { type AppLoadContext, type EntryContext, ServerRouter } from "react-router" |
9 | | -import { createHonoServer } from "react-router-hono-server/node" |
10 | | -import { i18next } from "remix-hono/i18next" |
11 | | -import { getClientEnv, initEnv } from "./env.server" |
12 | 8 | import i18n from "./localization/i18n" // your i18n configuration file |
13 | 9 | import i18nextOpts from "./localization/i18n.server" |
14 | 10 | import { resources } from "./localization/resource" |
| 11 | + |
15 | 12 | const ABORT_DELAY = 5000 |
16 | 13 |
|
17 | 14 | export default async function handleRequest( |
@@ -73,41 +70,3 @@ export default async function handleRequest( |
73 | 70 | setTimeout(abort, ABORT_DELAY) |
74 | 71 | }) |
75 | 72 | } |
76 | | - |
77 | | -// Code below used to initialize our own Hono server! |
78 | | -// Setup the .env vars |
79 | | -const env = initEnv() |
80 | | - |
81 | | -const getLoadContext = async (c: Context) => { |
82 | | - // get the locale from the context |
83 | | - const locale = i18next.getLocale(c) |
84 | | - // get t function for the default namespace |
85 | | - const t = await i18next.getFixedT(c) |
86 | | - |
87 | | - const clientEnv = getClientEnv() |
88 | | - return { |
89 | | - lang: locale, |
90 | | - t, |
91 | | - env, |
92 | | - clientEnv, |
93 | | - // We do not add this to AppLoadContext type because it's not needed in the loaders, but it's used above to handle requests |
94 | | - body: c.body, |
95 | | - } |
96 | | -} |
97 | | - |
98 | | -interface LoadContext extends Awaited<ReturnType<typeof getLoadContext>> {} |
99 | | - |
100 | | -/** |
101 | | - * Declare our loaders and actions context type |
102 | | - */ |
103 | | -declare module "react-router" { |
104 | | - interface AppLoadContext extends Omit<LoadContext, "body"> {} |
105 | | -} |
106 | | - |
107 | | -export const server = await createHonoServer({ |
108 | | - configure(server) { |
109 | | - server.use("*", i18next(i18nextOpts)) |
110 | | - }, |
111 | | - defaultLogger: false, |
112 | | - getLoadContext, |
113 | | -}) |
0 commit comments