|
|
@@ -1,6 +1,14 @@
|
|
|
+// app/api/files/route.js
|
|
|
import { NextResponse } from "next/server";
|
|
|
import { listFiles } from "@/lib/storage";
|
|
|
|
|
|
+/**
|
|
|
+ * GET /api/files?branch=&year=&month=&day=
|
|
|
+ *
|
|
|
+ * Returns the list of PDF files for a specific branch + date.
|
|
|
+ * Example:
|
|
|
+ * /api/files?branch=NL01&year=2024&month=10&day=23
|
|
|
+ */
|
|
|
export async function GET(request) {
|
|
|
const { searchParams } = new URL(request.url);
|
|
|
const branch = searchParams.get("branch");
|
|
|
@@ -10,6 +18,7 @@ export async function GET(request) {
|
|
|
|
|
|
console.log("[/api/files] query:", { branch, year, month, day });
|
|
|
|
|
|
+ // Validate required query params
|
|
|
if (!branch || !year || !month || !day) {
|
|
|
return NextResponse.json(
|
|
|
{ error: "branch, year, month, day sind erforderlich" },
|
|
|
@@ -19,9 +28,11 @@ export async function GET(request) {
|
|
|
|
|
|
try {
|
|
|
const files = await listFiles(branch, year, month, day);
|
|
|
+
|
|
|
return NextResponse.json({ branch, year, month, day, files });
|
|
|
} catch (error) {
|
|
|
- console.error("[/api/files] Fehler:", error);
|
|
|
+ console.error("[/api/files] Error:", error);
|
|
|
+
|
|
|
return NextResponse.json(
|
|
|
{ error: "Fehler beim Lesen der Dateien: " + error.message },
|
|
|
{ status: 500 }
|