perf : not ask me i copy from another projeft

This commit is contained in:
2026-07-08 21:02:39 +07:00 Unverified
parent 4317853aca
commit 5fd165e2b6
11 changed files with 163 additions and 310 deletions
+10 -2
View File
@@ -2,5 +2,13 @@ import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import * as schema from "./schema";
const client = postgres(process.env.DATABASE_URL!);
export const db = drizzle(client, { schema });
const globalForDb = globalThis as unknown as { pgClient: ReturnType<typeof postgres> };
if (!globalForDb.pgClient) {
globalForDb.pgClient = postgres(process.env.DATABASE_URL!, {
max: 5,
idle_timeout: 20,
});
}
export const db = drizzle(globalForDb.pgClient, { schema });