feat: Add OCR Processing Layers Viewer UI and log proxy middleware

This commit is contained in:
Rafhan Mazaya Fathurrahman committed 2026-07-01 08:45:45 +07:00
1 parent 54b46fc35f
commit aa3233e411
11 files changed
+964 -30

No files matched your search

@@ -0,0 +1,37 @@
import { NextRequest, NextResponse } from "next/server";
import { query } from "../../../../../db";
export const dynamic = "force-dynamic";
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ id: string }> | { id: string } }
) {
try {
// Handle both Promise and synchronous params for Next.js version compatibility
const resolvedParams = await params;
const { id } = resolvedParams;
const docId = parseInt(id, 10);
if (isNaN(docId)) {
return NextResponse.json({ error: "Invalid document ID" }, { status: 400 });
}
const res = await query(
"SELECT filename, processing_logs FROM documents WHERE id = $1",
[docId]
);
if (res.rowCount === 0 || !res.rows[0]) {
return NextResponse.json({ error: "Document not found" }, { status: 404 });
}
return NextResponse.json({
filename: res.rows[0].filename,
processing_logs: res.rows[0].processing_logs || null
});
} catch (error: any) {
console.error("Error fetching document logs:", error);
return NextResponse.json({ error: error.message }, { status: 500 });
}
}