initial commit: project completion with proper gitignore
This commit is contained in:
13
lib/db.ts
Normal file
13
lib/db.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import postgres from 'postgres';
|
||||
|
||||
const globalForSql = global as unknown as { sql: postgres.Sql<{}> };
|
||||
|
||||
const sql = globalForSql.sql || postgres(process.env.DATABASE_URL!, {
|
||||
max: 10, // Limit maximum connections
|
||||
idle_timeout: 20, // Close idle connections after 20 seconds
|
||||
connect_timeout: 10,
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') globalForSql.sql = sql;
|
||||
|
||||
export default sql;
|
||||
Reference in New Issue
Block a user