mirror of
https://github.com/soconnor0919/hristudio.git
synced 2025-12-11 22:54:45 -05:00
24 lines
648 B
TypeScript
24 lines
648 B
TypeScript
import { drizzle } from "drizzle-orm/postgres-js";
|
|
import postgres from "postgres";
|
|
|
|
import { env } from "~/env";
|
|
import * as schema from "./schema";
|
|
|
|
/**
|
|
* Cache the database connection in development. This avoids creating a new connection on every HMR
|
|
* update.
|
|
*/
|
|
const globalForDb = globalThis as unknown as {
|
|
conn: postgres.Sql | undefined;
|
|
};
|
|
|
|
const conn = globalForDb.conn ?? postgres(env.DATABASE_URL);
|
|
if (env.NODE_ENV !== "production") globalForDb.conn = conn;
|
|
|
|
export const db = drizzle(conn, { schema });
|
|
|
|
import { initializeContentTypes } from "./init";
|
|
|
|
// Initialize content types
|
|
initializeContentTypes().catch(console.error);
|