route.js 825 B

123456789101112131415161718192021222324252627282930
  1. // app/api/files/route.js
  2. import { NextResponse } from "next/server";
  3. import { listFiles } from "@/lib/storage";
  4. export async function GET(request) {
  5. const { searchParams } = new URL(request.url);
  6. const branch = searchParams.get("branch");
  7. const year = searchParams.get("year");
  8. const month = searchParams.get("month");
  9. const day = searchParams.get("day");
  10. if (!branch || !year || !month || !day) {
  11. return NextResponse.json(
  12. { error: "branch, year, month, day sind erforderlich" },
  13. { status: 400 }
  14. );
  15. }
  16. try {
  17. const files = await listFiles(branch, year, month, day);
  18. return NextResponse.json({ branch, year, month, day, files });
  19. } catch (error) {
  20. console.error("[api/files] Fehler:", error);
  21. return NextResponse.json(
  22. { error: "Fehler beim Lesen der Dateien" },
  23. { status: 500 }
  24. );
  25. }
  26. }