Initial commit: Kalendartool (Next.js, Prisma, Docker)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Kühn
2026-10-08 14:38:04 +02:00
commit bc49c3074e
94 changed files with 12812 additions and 0 deletions

23
lib/db/client.ts Normal file
View File

@@ -0,0 +1,23 @@
import { PrismaClient } from '@prisma/client';
/**
* Globaler Prisma-Client.
*
* In der Entwicklung startet Next.js bei Hot Reload mehrfach Modul-Instanzen;
* ohne Caching wuerde jede Instanz eigene Verbindungen aufbauen und die
* Datenbank mit Verbindungen ueberfluten. Daher wird die Instanz auf
* `globalThis` gecacht (offizielles Prisma-Rezept fuer Next.js).
*/
const globalForPrisma = globalThis as unknown as {
prisma: PrismaClient | undefined;
};
export const prisma: PrismaClient =
globalForPrisma.prisma ??
new PrismaClient({
log: process.env.NODE_ENV === 'development' ? ['warn', 'error'] : ['error'],
});
if (process.env.NODE_ENV !== 'production') {
globalForPrisma.prisma = prisma;
}