| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- // 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");
- const year = searchParams.get("year");
- const month = searchParams.get("month");
- const day = searchParams.get("day");
- 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" },
- { status: 400 }
- );
- }
- try {
- const files = await listFiles(branch, year, month, day);
- return NextResponse.json({ branch, year, month, day, files });
- } catch (error) {
- console.error("[/api/files] Error:", error);
- return NextResponse.json(
- { error: "Fehler beim Lesen der Dateien: " + error.message },
- { status: 500 }
- );
- }
- }
|