2026-08-25 07:51:38 +02:00
|
|
|
import { NextResponse } from "next/server";
|
|
|
|
|
import { sqlite } from "@/lib/db/client";
|
2026-08-26 08:45:15 +02:00
|
|
|
import { withRouteLogging } from "@/lib/api/with-route-logging";
|
|
|
|
|
import { createLogger } from "@/lib/logger";
|
2026-08-25 07:51:38 +02:00
|
|
|
|
2026-08-26 08:45:15 +02:00
|
|
|
const log = createLogger("health");
|
|
|
|
|
|
|
|
|
|
export const GET = withRouteLogging("health.check", async () => {
|
2026-08-25 07:51:38 +02:00
|
|
|
try {
|
|
|
|
|
sqlite.prepare("select 1").get();
|
|
|
|
|
return NextResponse.json({ status: "ok" });
|
2026-08-26 08:45:15 +02:00
|
|
|
} catch (err) {
|
|
|
|
|
log.error("health check failed", { error: err instanceof Error ? err.message : String(err) });
|
2026-08-25 07:51:38 +02:00
|
|
|
return NextResponse.json({ status: "error" }, { status: 500 });
|
|
|
|
|
}
|
2026-08-26 08:45:15 +02:00
|
|
|
});
|