perf(db): better control over how we stay connected

This commit is contained in:
2025-04-14 22:14:41 -05:00
parent 7a3732d5b2
commit 2eafbdf45e

View File

@@ -1,4 +1,4 @@
import {drizzle} from "drizzle-orm/postgres-js";
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import dotenv from "dotenv";
@@ -6,6 +6,17 @@ dotenv.config();
const database = process.env.DATABASE_URL || "";
const queryClient = postgres(database);
const queryClient = postgres(database, {
max: 10,
idle_timeout: 60,
connect_timeout: 10,
max_lifetime: 1000 * 60 * 5,
onnotice: (notice) => {
console.log("PG NOTICE:", notice.message);
},
// debug: (...args) => {
// console.log("QUERY DEBUG:", ...args);
// },
});
export const db = drizzle({client: queryClient});
export const db = drizzle({ client: queryClient });