drop db interface, use kysely instead for more more flexibility (at the cost of more coupling)

This commit is contained in:
Avraham Sakal
2025-09-21 17:14:27 -04:00
parent 21931a20cb
commit 360bfc6df3
8 changed files with 139 additions and 362 deletions
+5 -5
View File
@@ -1,6 +1,6 @@
import type { PageContextServer } from "vike/types";
import { createCaller } from "../../../server/trpc/chat.js";
import { getDb } from "../../../database/postgres.js";
import { getDbClient } from "../../../database/postgres.js";
import { getOpenrouter } from "../../../server/provider.js";
import { env } from "../../../server/env.js";
@@ -9,14 +9,14 @@ export type Data = Awaited<ReturnType<typeof data>>;
export const data = async (pageContext: PageContextServer) => {
const { id } = pageContext.routeParams;
const caller = createCaller({
db: getDb(
(pageContext.env?.POSTGRES_CONNECTION_STRING ||
env.POSTGRES_CONNECTION_STRING) as string
),
openrouter: getOpenrouter(
(pageContext.env?.OPENROUTER_API_KEY || env.OPENROUTER_API_KEY) as string
),
// jwt: pageContext.,
dbClient: getDbClient(
(pageContext.env?.POSTGRES_CONNECTION_STRING ||
env.POSTGRES_CONNECTION_STRING) as string
),
});
const [