- Replace all `any` types with proper types or `unknown` across ~20 files - Add typed socket payload interfaces in draft route and useDraftSocket - Use any[] with eslint-disable for socket.io callbacks (legitimate escape hatch) - Bump all tsconfigs from ES2022 → ES2023 to support toSorted/toReversed - Fix cascading type errors uncovered by removing any: Map.get narrowing, participant relation types, ChartDataPoint, Partial<NewSeason> indexing - Add ParticipantResultWithParticipant type to participant-result model - Fix test fixtures to match updated interfaces (DraftCell, ParticipantResult) - Fix duplicate getQPStandings import in sportsSeasonId.server.ts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
import { createRequestHandler } from "@react-router/express";
|
|
import { drizzle } from "drizzle-orm/postgres-js";
|
|
import express from "express";
|
|
import postgres from "postgres";
|
|
import type { ServerBuild } from "react-router";
|
|
import { RouterContextProvider } from "react-router";
|
|
|
|
import { DatabaseContext } from "~/database/context";
|
|
import * as schema from "~/database/schema";
|
|
import { expressValueContext } from "~/contexts/express";
|
|
|
|
export const app = express();
|
|
|
|
if (!process.env.DATABASE_URL) throw new Error("DATABASE_URL is required");
|
|
|
|
const client = postgres(process.env.DATABASE_URL);
|
|
const db = drizzle(client, { schema });
|
|
app.use((_, __, next) => DatabaseContext.run(db, next));
|
|
|
|
app.use(
|
|
createRequestHandler({
|
|
build: () => import("virtual:react-router/server-build") as unknown as Promise<ServerBuild>,
|
|
// @ts-ignore -- RouterContextProvider is the correct runtime type but tsconfig.server.json can't resolve the conditional type statically
|
|
getLoadContext() {
|
|
const provider = new RouterContextProvider();
|
|
provider.set(expressValueContext, "Hello from Express");
|
|
return provider as unknown as RouterContextProvider;
|
|
},
|
|
}),
|
|
);
|