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;
|
let normalized = 0;
|
||||||
for (const r of titleRows) {
|
for (const r of titleRows) {
|
||||||
const canonical = canonicalByLang.get(r.language);
|
const canonical = canonicalByLang.get(r.language) ?? null;
|
||||||
if (r.title === canonical) continue;
|
if (r.title === canonical) continue;
|
||||||
|
|
||||||
// Find all streams matching this language+title and set custom_title on their decisions
|
// 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 ─────────────────────────────────────────────────────────────
|
// ─── SPA fallback ─────────────────────────────────────────────────────────────
|
||||||
// All non-API routes serve the React index.html so TanStack Router handles them.
|
// All non-API routes serve the React index.html so TanStack Router handles them.
|
||||||
|
|
||||||
app.get("*", (c) => {
|
app.get("*", async (c) => {
|
||||||
const _accept = c.req.header("Accept") ?? "";
|
|
||||||
if (c.req.path.startsWith("/api/")) return c.notFound();
|
if (c.req.path.startsWith("/api/")) return c.notFound();
|
||||||
// In dev the Vite server handles the SPA. In production serve dist/index.html.
|
// In dev the Vite server handles the SPA. In production serve dist/index.html.
|
||||||
try {
|
try {
|
||||||
const html = Bun.file("./dist/index.html").text();
|
const html = await Bun.file("./dist/index.html").text();
|
||||||
return html.then((text) => c.html(text));
|
return c.html(html);
|
||||||
} catch {
|
} catch {
|
||||||
return c.text("Run `bun build` first to generate the frontend.", 503);
|
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": {
|
"files": [],
|
||||||
"target": "ESNext",
|
"references": [
|
||||||
"module": "ESNext",
|
{ "path": "./tsconfig.client.json" },
|
||||||
"moduleResolution": "bundler",
|
{ "path": "./tsconfig.server.json" }
|
||||||
"jsx": "react-jsx",
|
]
|
||||||
"strict": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
||||||
"baseUrl": ".",
|
|
||||||
"paths": {
|
|
||||||
"~/*": ["./src/*"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"include": ["src/**/*", "vite.config.ts"]
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user