xonecas.io
53129
Pa

PAT / files

PAT / src / lib / db / index.ts

540 bytes
1import { drizzle } from "drizzle-orm/postgres-js";
2import postgres from "postgres";
3import * as schema from "./schema";
4
5// Get database connection string from environment variable
6const connectionString = process.env.DATABASE_URL;
7
8if (!connectionString) {
9  throw new Error("DATABASE_URL environment variable is not set");
10}
11
12// Create postgres client
13const client = postgres(connectionString, {
14  max: 1, // Limit connection pool for serverless environments
15});
16
17// Create drizzle instance
18export const db = drizzle(client, { schema });