create-jaydee-app
Version:
This is a project created with Create Jaydee App.
17 lines (12 loc) • 491 B
text/typescript
import { createClient, type Client } from "@libsql/client";
import { drizzle } from "drizzle-orm/libsql";
import { env } from "~/env";
import * as schema from "./schema";
const globalForDb = globalThis as unknown as {
client: Client | undefined;
};
export const client =
globalForDb.client ??
createClient({ url: env.DATABASE_URL, authToken: env.DATABASE_AUTH_TOKEN });
if (env.NODE_ENV !== "production") globalForDb.client = client;
export const db = drizzle(client, { schema });