Something went wrong. Try again.
Japanese learning that pulls JA Bluesky posts, scores them per-token, and serves them thricely.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829// Process-wide singleton pg pool + StoreOps. Next.js may re-evaluate this// module in dev; Node guarantees per-module singletons in a single process,// which is what we want for the connection pool.//// `getPool()` is exposed for callers that need atomic multi-statement work// via @yominoki/db `withTransaction(pool, fn)`. Routine query/run callers// should use `getOps()`.
import { createNodeClientWithPool } from "@yominoki/db/client"import { env } from "./env"
type Bundle = ReturnType<typeof createNodeClientWithPool>
let cached: Bundle | null = null
function get(): Bundle { if (cached) return cached cached = createNodeClientWithPool(env.cockroachUrl) return cached}
export function getPool(): Bundle["pool"] { return get().pool}
export function getOps(): Bundle["ops"] { return get().ops}