mirror of
https://github.com/R0m1k3/PleinR.git
synced 2026-10-11 17:27:54 +02:00
Application unique Next.js (App Router, TypeScript) servant : - Accueil public : héro, recherche, métiers, promotions, mises à l'honneur (données issues de Postgres) - Backend authentifié avec RBAC : tableau de bord, adhérents (CRUD), modération des promotions, administrateurs, espace adhérent (publication avec aperçu) Technique : - Drizzle ORM + drizzle-kit (migrations versionnées) sur driver pg - Auth.js v5 (credentials, sessions JWT), rôles admin/moderator/editor/member - Middleware de protection de /backend + gardes par rôle dans chaque vue - Server actions pour toutes les mutations (vérif auth + capacité + revalidate) - Design fidèle aux maquettes (design-system CSS, animations, responsive) Conteneurisation : - 1 conteneur applicatif (sortie standalone) + 1 conteneur Postgres externe - docker-compose avec healthcheck ; migrations + seed au démarrage - scripts migrate/seed bundlés (esbuild) pour un runtime sans devDeps Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XwfhYHzC9hQWPDnQ2p53GL
26 lines
677 B
TypeScript
26 lines
677 B
TypeScript
import { drizzle } from "drizzle-orm/node-postgres";
|
|
import { Pool } from "pg";
|
|
import * as schema from "./schema";
|
|
|
|
const connectionString = process.env.DATABASE_URL;
|
|
if (!connectionString) {
|
|
throw new Error("DATABASE_URL is not set");
|
|
}
|
|
|
|
// Reuse the pool across hot reloads in dev to avoid exhausting connections.
|
|
const globalForDb = globalThis as unknown as { __pleinrPool?: Pool };
|
|
|
|
export const pool =
|
|
globalForDb.__pleinrPool ??
|
|
new Pool({
|
|
connectionString,
|
|
max: Number(process.env.PG_POOL_MAX ?? 10),
|
|
});
|
|
|
|
if (process.env.NODE_ENV !== "production") {
|
|
globalForDb.__pleinrPool = pool;
|
|
}
|
|
|
|
export const db = drizzle(pool, { schema });
|
|
export { schema };
|