- Erweiterbare Registry aller 15 QR-Typen; nur "Website" ist aktiv, die
uebrigen erscheinen als Platzhalter mit Badge "Bald verfuegbar".
- defineQrType() kapselt Zod-Schema, Kodierung und Redirect-Ziel je Typ,
sodass ein V2-Typ nur aus einem Registry-Eintrag plus Formular besteht.
- Serverseitige QR-Erzeugung (PNG/SVG) mit Farben, Groesse, Fehlerkorrektur
und Rand; Live-Vorschau ueber /api/qr/preview.
- Dynamische Codes: Kurz-URL {BASE_URL}/r/{slug}, 302-Redirect mit
Scan-Zaehler, CRUD unter /api/codes.
- Prisma 7 mit pg-Driver-Adapter und Initial-Migration fuer PostgreSQL.
- Deutsche Oberflaeche mit Tailwind CSS, helles Theme, responsiv.
25 lines
715 B
TypeScript
25 lines
715 B
TypeScript
import "server-only";
|
|
|
|
import { PrismaPg } from "@prisma/adapter-pg";
|
|
|
|
import { PrismaClient } from "@/generated/prisma/client";
|
|
import { getDatabaseUrl } from "@/lib/env";
|
|
|
|
// Im Entwicklungsmodus wird das Modul bei jedem Hot-Reload neu ausgewertet.
|
|
// Ohne diesen Cache entstünde pro Reload ein neuer Verbindungspool.
|
|
const globalForPrisma = globalThis as unknown as {
|
|
prisma?: ReturnType<typeof createPrismaClient>;
|
|
};
|
|
|
|
function createPrismaClient() {
|
|
return new PrismaClient({
|
|
adapter: new PrismaPg({ connectionString: getDatabaseUrl() }),
|
|
});
|
|
}
|
|
|
|
export const prisma = globalForPrisma.prisma ?? createPrismaClient();
|
|
|
|
if (process.env.NODE_ENV !== "production") {
|
|
globalForPrisma.prisma = prisma;
|
|
}
|