Docker-Stack, README und Korrekturen aus dem ersten Durchlauf

- Dockerfile (4 Stufen) und docker-compose.yml mit Postgres-Healthcheck,
  Volume und direktem Port-Mapping 3000:3000, ohne Reverse Proxy.
- Entrypoint wendet beim Start "prisma migrate deploy" an; die Prisma-CLI
  bekommt eine eigene Build-Stufe, weil sie mehr als nur @prisma/* braucht.
- prisma.config.ts durch prisma.config.js ersetzt: laedt ohne TypeScript und
  ohne dotenv, damit sie im Laufzeit-Image funktioniert.
- Prisma-Client wird erst beim ersten Zugriff erzeugt. Vorher scheiterte
  "next build" beim Einsammeln der Routen-Konfiguration ohne DATABASE_URL.
- Postgres-18-Volume auf /var/lib/postgresql gemountet (neues Datenlayout).
- npm 11 blockiert Installationsskripte: erlaubte Pakete stehen jetzt im
  Feld "allowScripts" der package.json.
- Lokale Variable "module" ueberall in "qrType" umbenannt (verdeckte sonst
  die CommonJS-Variable) und Vorschau-Effekt ohne synchrones setState.
- README.md auf Deutsch: Setup, Konfiguration, Bedienung, Aufbau, API und
  Ausblick auf Version 2.
This commit is contained in:
Florian Wilde
2026-08-13 16:48:28 +02:00
parent ad4cd92f8e
commit 5806dc4ce0
26 changed files with 751 additions and 129 deletions
+3 -3
View File
@@ -55,9 +55,9 @@ export async function GET(
};
if (isDownload) {
const module = getQrType(code.type);
const name = module
? downloadFilename(module, code.data, format)
const qrType = getQrType(code.type);
const name = qrType
? downloadFilename(qrType, code.data, format)
: `qr-${code.slug}.${format}`;
headers["Content-Disposition"] = `attachment; filename="${name}"`;
}
+3 -3
View File
@@ -60,13 +60,13 @@ export async function PATCH(
const update: Prisma.QrCodeUpdateInput = {};
if (parsed.data.data !== undefined) {
const module = getActiveQrType(existing.type);
if (!module) {
const qrType = getActiveQrType(existing.type);
if (!qrType) {
throw new QrRequestError(
"Der Typ dieses Codes wird in dieser Version nicht unterstützt.",
);
}
const validated = module.validate(parsed.data.data);
const validated = qrType.validate(parsed.data.data);
if (!validated.ok) {
return jsonError(validated.message);
}
+6 -6
View File
@@ -51,20 +51,20 @@ export async function POST(request: NextRequest): Promise<Response> {
}
const { type, design, label } = parsed.data;
const module = getActiveQrType(type);
if (!module) {
const qrType = getActiveQrType(type);
if (!qrType) {
throw new QrRequestError(
"Dieser QR-Typ ist in dieser Version noch nicht verfügbar.",
404,
);
}
if (!module.supportsDynamic) {
if (!qrType.supportsDynamic) {
throw new QrRequestError(
`Der QR-Typ „${module.title}" unterstützt keine dynamischen Codes.`,
`Der QR-Typ „${qrType.title}“ unterstützt keine dynamischen Codes.`,
);
}
const validated = module.validate(parsed.data.data);
const validated = qrType.validate(parsed.data.data);
if (!validated.ok) {
return jsonError(validated.message);
}
@@ -75,7 +75,7 @@ export async function POST(request: NextRequest): Promise<Response> {
const created = await prisma.qrCode.create({
data: {
slug: generateSlug(),
type: module.id,
type: qrType.id,
label: label && label.length > 0 ? label : null,
data: toJsonInput(validated.data),
...design,
+2 -2
View File
@@ -31,7 +31,7 @@ export async function POST(request: NextRequest): Promise<Response> {
);
}
const { module, data, content } = resolveQrRequest(parsed.data);
const { qrType, data, content } = resolveQrRequest(parsed.data);
const body =
format === "png"
@@ -41,7 +41,7 @@ export async function POST(request: NextRequest): Promise<Response> {
return new Response(body, {
headers: {
"Content-Type": CONTENT_TYPES[format],
"Content-Disposition": `attachment; filename="${downloadFilename(module, data, format)}"`,
"Content-Disposition": `attachment; filename="${downloadFilename(qrType, data, format)}"`,
"Cache-Control": "no-store",
},
});
+7 -7
View File
@@ -15,15 +15,15 @@ export function generateStaticParams() {
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { type } = await params;
const module = getQrType(type);
return { title: module ? `${module.title}-QR-Code` : "QR-Code erstellen" };
const qrType = getQrType(type);
return { title: qrType ? `${qrType.title}-QR-Code` : "QR-Code erstellen" };
}
export default async function CreatePage({ params }: Props) {
const { type } = await params;
const module = getQrType(type);
const qrType = getQrType(type);
if (!module) {
if (!qrType) {
notFound();
}
@@ -33,10 +33,10 @@ export default async function CreatePage({ params }: Props) {
return (
<div className="mx-auto max-w-2xl px-4 py-16 text-center sm:px-6">
<span className="mx-auto flex size-14 items-center justify-center rounded-2xl bg-slate-100 text-slate-400">
<Icon name={module.icon} className="size-7" />
<Icon name={qrType.icon} className="size-7" />
</span>
<h1 className="mt-5 text-2xl font-bold text-slate-900">
„{module.title}“ ist bald verfügbar
„{qrType.title}“ ist bald verfügbar
</h1>
<p className="mt-2 text-slate-600">
Dieser QR-Typ folgt in Version 2. In Version 1 steht der Typ „Website“
@@ -52,5 +52,5 @@ export default async function CreatePage({ params }: Props) {
);
}
return <QrGenerator typeId={module.id} />;
return <QrGenerator typeId={qrType.id} />;
}
+1 -1
View File
@@ -49,7 +49,7 @@ export default function RootLayout({ children }: LayoutProps<"/">) {
<footer className="border-t border-slate-200 bg-white">
<div className="mx-auto max-w-6xl px-4 py-6 text-sm text-slate-500 sm:px-6">
QR-Code-Generator · Version 1 — QR-Typ „Website/URL"
QR-Code-Generator · Version 1 — QR-Typ „Website/URL“
</div>
</footer>
</body>
+2 -2
View File
@@ -73,7 +73,7 @@ export default function HomePage() {
) : (
<div
aria-disabled="true"
title={`„${type.title}" folgt in Version 2`}
title={`„${type.title}“ folgt in Version 2`}
className="flex h-full cursor-not-allowed items-start gap-4 rounded-2xl border border-dashed border-slate-200 bg-slate-50/60 p-4"
>
{tile}
@@ -85,7 +85,7 @@ export default function HomePage() {
</ul>
<p className="mt-8 text-sm text-slate-500">
In Version 1 ist der Typ „Website" verfügbar. Die übrigen Typen folgen in
In Version 1 ist der Typ „Website“ verfügbar. Die übrigen Typen folgen in
Version 2.
</p>
</div>
+3 -3
View File
@@ -52,14 +52,14 @@ export async function GET(
);
}
const module = getQrType(code.type);
if (!module) {
const qrType = getQrType(code.type);
if (!qrType) {
return notFound("Der Typ dieses Codes wird nicht mehr unterstützt.");
}
let target: string;
try {
target = module.redirectTarget(code.data);
target = qrType.redirectTarget(code.data);
} catch {
return notFound("Das Ziel dieses Codes ist nicht mehr gültig.");
}