Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history

index.ts

Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.

index.tsBlame26 lines · 1 contributor
fc1817aClaude1import { neon } from "@neondatabase/serverless";
2import { drizzle, type NeonHttpDatabase } from "drizzle-orm/neon-http";
3import * as schema from "./schema";
4import { config } from "../lib/config";
5
6let _db: NeonHttpDatabase<typeof schema> | null = null;
7
8export function getDb(): NeonHttpDatabase<typeof schema> {
9 if (!_db) {
10 if (!config.databaseUrl) {
11 throw new Error(
12 "DATABASE_URL is not set. Set it in your environment or .env file."
13 );
14 }
15 const sql = neon(config.databaseUrl);
16 _db = drizzle(sql, { schema });
17 }
18 return _db;
19}
20
21// Re-export as `db` for convenience — will throw on access without DATABASE_URL
22export const db = new Proxy({} as NeonHttpDatabase<typeof schema>, {
23 get(_target, prop, receiver) {
24 return Reflect.get(getDb(), prop, receiver);
25 },
26});