fix server typecheck: use tsconfig project references, await bun file in spa fallback
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
- split tsconfig.json into project references (client + server) so bun-types and DOM types don't leak into the other side; server now resolves Bun.* without diagnostics - client tsconfig adds vite/client types so import.meta.env typechecks - index.tsx spa fallback: use async/await + c.html(await …) instead of returning a Promise of a Response, which Hono's Handler type rejects - subtitles normalize-titles: narrow canonical to string|null (Map.get widened to include undefined)
This commit is contained in:
@@ -594,7 +594,7 @@ app.post("/normalize-titles", (c) => {
|
||||
|
||||
let normalized = 0;
|
||||
for (const r of titleRows) {
|
||||
const canonical = canonicalByLang.get(r.language);
|
||||
const canonical = canonicalByLang.get(r.language) ?? null;
|
||||
if (r.title === canonical) continue;
|
||||
|
||||
// Find all streams matching this language+title and set custom_title on their decisions
|
||||
|
||||
@@ -49,13 +49,12 @@ app.use("/favicon.ico", serveStatic({ path: "./dist/favicon.ico" }));
|
||||
// ─── SPA fallback ─────────────────────────────────────────────────────────────
|
||||
// All non-API routes serve the React index.html so TanStack Router handles them.
|
||||
|
||||
app.get("*", (c) => {
|
||||
const _accept = c.req.header("Accept") ?? "";
|
||||
app.get("*", async (c) => {
|
||||
if (c.req.path.startsWith("/api/")) return c.notFound();
|
||||
// In dev the Vite server handles the SPA. In production serve dist/index.html.
|
||||
try {
|
||||
const html = Bun.file("./dist/index.html").text();
|
||||
return html.then((text) => c.html(text));
|
||||
const html = await Bun.file("./dist/index.html").text();
|
||||
return c.html(html);
|
||||
} catch {
|
||||
return c.text("Run `bun build` first to generate the frontend.", 503);
|
||||
}
|
||||
|
||||
18
tsconfig.client.json
Normal file
18
tsconfig.client.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"jsx": "react-jsx",
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"types": ["vite/client"],
|
||||
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"~/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*", "vite.config.ts"]
|
||||
}
|
||||
1
tsconfig.client.tsbuildinfo
Normal file
1
tsconfig.client.tsbuildinfo
Normal file
File diff suppressed because one or more lines are too long
@@ -1,16 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"jsx": "react-jsx",
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"~/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*", "vite.config.ts"]
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.client.json" },
|
||||
{ "path": "./tsconfig.server.json" }
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user