mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 21:32:10 +03:00
19 lines
665 B
TypeScript
19 lines
665 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { listFiles } from "@/lib/localDb";
|
|
import { requireManagementAuth } from "@/lib/api/requireManagementAuth";
|
|
|
|
export async function GET(request: Request) {
|
|
const authError = await requireManagementAuth(request);
|
|
if (authError) return authError;
|
|
|
|
try {
|
|
const url = new URL(request.url);
|
|
const limit = Number.parseInt(url.searchParams.get("limit") || "100", 10);
|
|
const files = listFiles({ limit });
|
|
return NextResponse.json({ files });
|
|
} catch (error) {
|
|
console.log("Error fetching files:", error);
|
|
return NextResponse.json({ error: "Failed to fetch files" }, { status: 500 });
|
|
}
|
|
}
|