Download src/db/index.ts from lljz66/api: direct link, hf CLI and curl.
- Browser
- Download file 546 Bytes
-
https://huggingface.co/spaces/lljz66/api/resolve/main/src/db/index.ts
- Command line
-
hf download hf://spaces/lljz66/api/src/db/index.ts
-
curl -L -o index.ts https://huggingface.co/spaces/lljz66/api/resolve/main/src/db/index.ts
546 Bytes
| import { drizzle } from "drizzle-orm/node-postgres"; | |
| import { Pool } from "pg"; | |
| const databaseUrl = process.env.DATABASE_URL; | |
| if (!databaseUrl) { | |
| throw new Error("DATABASE_URL is required"); | |
| } | |
| const globalForDb = globalThis as typeof globalThis & { | |
| __arenaNextJsPostgresqlPool?: Pool; | |
| }; | |
| export const pool = | |
| globalForDb.__arenaNextJsPostgresqlPool ?? | |
| new Pool({ | |
| connectionString: databaseUrl, | |
| }); | |
| if (process.env.NODE_ENV !== "production") { | |
| globalForDb.__arenaNextJsPostgresqlPool = pool; | |
| } | |
| export const db = drizzle(pool); |