Files
neta/app/api/v1/health/route.ts
T

28 lines
678 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { apiV1Error, apiV1Success } from "@/server/api/v1/responses";
import { checkReadiness } from "@/server/db/health";
import { DomainError } from "@/server/domain/errors";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export function GET() {
const readiness = checkReadiness();
const checkedAt = new Date().toISOString();
if (!readiness.ok) {
return apiV1Error(
new DomainError(
"SERVICE_UNAVAILABLE",
"Instance henüz isteklere hazır değil.",
{ checks: readiness.checks, checkedAt },
),
);
}
return apiV1Success({
status: "ok",
checks: readiness.checks,
checkedAt,
});
}