a36436d128
Sets up the initial project structure for groombook/groombook: - pnpm monorepo with apps/api (Hono + TypeScript), apps/web (React + Vite + PWA), packages/db (Drizzle ORM), packages/types (shared types) - Core DB schema: clients, pets, services, appointments, staff with CNPG-compatible Postgres - REST API routes for clients, pets, services, appointments with Zod validation - OIDC auth middleware for Authentik integration - React PWA with vite-plugin-pwa, service worker, offline caching, installable manifest - GitHub Actions CI: lint, typecheck, test, build, Docker image build (groombook-runners) - Dockerfiles for API (Node.js) and Web (nginx) - docker-compose.yml for local development Co-Authored-By: Paperclip <noreply@paperclip.ing>
19 lines
493 B
TypeScript
19 lines
493 B
TypeScript
import { drizzle } from "drizzle-orm/postgres-js";
|
|
import postgres from "postgres";
|
|
import * as schema from "./schema.js";
|
|
|
|
export * from "./schema.js";
|
|
|
|
let _db: ReturnType<typeof drizzle> | null = null;
|
|
|
|
export function getDb() {
|
|
if (_db) return _db;
|
|
const url = process.env.DATABASE_URL;
|
|
if (!url) throw new Error("DATABASE_URL is not set");
|
|
const client = postgres(url, { max: 10 });
|
|
_db = drizzle(client, { schema });
|
|
return _db;
|
|
}
|
|
|
|
export type Db = ReturnType<typeof getDb>;
|