Every app/api route handler now goes through withRouteLogging, which logs a correlated reqId/method/path/status/duration for each request and turns any uncaught error into a logged stack trace plus a clean JSON 500 instead of Next's default opaque failure. proxy.ts logs rejected auth attempts, and instrumentation.ts's onRequestError catches anything that still escapes a route handler. Also adds a minimal not-found page matching the app's card styling. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
17 lines
587 B
TypeScript
17 lines
587 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { sqlite } from "@/lib/db/client";
|
|
import { withRouteLogging } from "@/lib/api/with-route-logging";
|
|
import { createLogger } from "@/lib/logger";
|
|
|
|
const log = createLogger("health");
|
|
|
|
export const GET = withRouteLogging("health.check", async () => {
|
|
try {
|
|
sqlite.prepare("select 1").get();
|
|
return NextResponse.json({ status: "ok" });
|
|
} catch (err) {
|
|
log.error("health check failed", { error: err instanceof Error ? err.message : String(err) });
|
|
return NextResponse.json({ status: "error" }, { status: 500 });
|
|
}
|
|
});
|