fiddy/apps/web/app/api/health/ready/route.ts

26 lines
759 B
TypeScript

import { NextResponse } from "next/server";
import getPool from "@/lib/server/db";
import { getRequestMeta } from "@/lib/server/request";
import { toErrorResponse } from "@/lib/server/errors";
export async function GET() {
const { requestId } = await getRequestMeta();
try {
const pool = getPool();
await pool.query("select 1");
return NextResponse.json({
requestId,
request_id: requestId,
ok: true,
status: "ready"
});
} catch (e) {
const { status, body } = toErrorResponse(e, "GET /api/health/ready", requestId);
return NextResponse.json({
...body,
ok: false,
status: "not_ready"
}, { status });
}
}