初始化模版工程

This commit is contained in:
Cloud Bot
2026-03-20 07:33:46 +00:00
commit 23717e0ecd
386 changed files with 51675 additions and 0 deletions

19
db/index.ts Normal file
View File

@@ -0,0 +1,19 @@
import 'server-only'
import { drizzle } from 'drizzle-orm/postgres-js'
import postgres from 'postgres'
declare global {
var postgresClient: ReturnType<typeof postgres> | undefined
}
if (!process.env.DATABASE_URL) {
throw new Error('DATABASE_URL is not set')
}
if (!globalThis.postgresClient) {
globalThis.postgresClient = postgres(process.env.DATABASE_URL, {
prepare: false,
})
}
export const db = drizzle(globalThis.postgresClient)