first commit

This commit is contained in:
2025-08-28 11:34:44 +08:00
parent 7d4af4b135
commit 40db604d14
15 changed files with 718 additions and 114 deletions
+21
View File
@@ -0,0 +1,21 @@
import { NextResponse } from "next/server";
import { readFile } from "node:fs/promises";
import { safeJoinSitePath } from "@/lib/config";
import { analyzeLogs } from "@/lib/analyzeLogs";
export const runtime = "nodejs";
export async function GET(
_req: Request,
ctx: { params: Promise<{ dir: string }> }
) {
try {
const { dir } = await ctx.params;
const filePath = safeJoinSitePath(dir, "log", "access.log");
const content = await readFile(filePath, { encoding: "utf-8" });
const data = await analyzeLogs(content);
return NextResponse.json(data);
} catch (error) {
return NextResponse.json({ error: String(error) }, { status: 404 });
}
}