fix(db): enable database connection pooling in production (#1564)

* fix: enable database connection pooling in production

* debug: add diagnostic endpoints to test NODE_ENV and database pooling

* test: add connection testing endpoint to diagnose production delay

* redeuce num of concurrent connections
This commit is contained in:
Waleed
2025-10-07 10:27:33 -07:00
committed by GitHub
parent c2f0a95802
commit f03f395225
3 changed files with 4 additions and 13 deletions

View File

@@ -15,9 +15,8 @@ const socketDb = drizzle(
prepare: false,
idle_timeout: 10,
connect_timeout: 20,
max: 25,
max: 15,
onnotice: () => {},
debug: false,
}),
{ schema }
)

View File

@@ -13,7 +13,7 @@ const db = drizzle(
prepare: false,
idle_timeout: 15,
connect_timeout: 20,
max: 5,
max: 3,
onnotice: () => {},
}),
{ schema }

View File

@@ -14,16 +14,8 @@ const postgresClient = postgres(connectionString, {
prepare: false,
idle_timeout: 20,
connect_timeout: 30,
max: 80,
max: 30,
onnotice: () => {},
})
const drizzleClient = drizzle(postgresClient, { schema })
declare global {
// eslint-disable-next-line no-var
var database: PostgresJsDatabase<typeof schema> | undefined
}
export const db = globalThis.database || drizzleClient
if (process.env.NODE_ENV !== 'production') globalThis.database = db
export const db = drizzle(postgresClient, { schema })