SPB Git

spb/worthdoing Public

Autonomous investigation agent that discovers, challenges, and ranks things genuinely worth doing — Claude + Firecrawl, Next.js 16, PostgreSQL

TypeScript 91.5% SQL 5.8% CSS 2.2%
730 B · 29 lines typescript
Raw Blame History
1/**2 * WorthDoing.ai3 * Author: Simon-Pierre Boucher4 * Contact: contact@spboucher.ai5 * File: src/lib/db/client.ts6 * Description: Singleton Drizzle + postgres.js client (survives Next.js dev hot reloads).7 */8import { drizzle } from "drizzle-orm/postgres-js";9import postgres from "postgres";10import { env } from "@/lib/env";11import * as schema from "./schema";1213const globalForDb = globalThis as unknown as {14  __wdSql?: ReturnType<typeof postgres>;15};1617const sql =18  globalForDb.__wdSql ??19  postgres(env().DATABASE_URL, {20    max: 10,21    idle_timeout: 30,22    onnotice: () => {},23  });2425if (env().NODE_ENV !== "production") globalForDb.__wdSql = sql;2627export const db = drizzle(sql, { schema });28export type Db = typeof db;29