Files
buzz-sheet/app/api/healthz/route.ts
T
gunshiz f5b432a496
CI / Verify (push) Successful in 1m45s
CI / Build immutable images and deploy (push) Successful in 2m24s
fix : correct api healthz
2026-10-02 18:57:43 +07:00

34 lines
1.2 KiB
TypeScript

import { sql } from "drizzle-orm";
import { connection } from "next/server";
import { getDb } from "@/db/client";
import { checkReadiness } from "@/lib/health/readiness";
import { checkDiscordBot, checkLunaris, checkSlip2Go } from "@/lib/health/services";
import { getRedisClient } from "@/lib/redis/client";
export async function GET() {
await connection();
const deploymentId = process.env.NEXT_DEPLOYMENT_ID || "unknown";
const configuredTimeout = Number(process.env.HEALTHCHECK_TIMEOUT_MS || 2_500);
const timeoutMs = Number.isFinite(configuredTimeout)
? Math.max(100, Math.min(10_000, configuredTimeout))
: 2_500;
const result = await checkReadiness({
database: async () => {
await getDb().execute(sql`select 1`);
},
redis: async () => {
const client = await getRedisClient();
await client.ping();
},
slip2go: () => checkSlip2Go(AbortSignal.timeout(timeoutMs)),
discordBot: checkDiscordBot,
lunaris: () => checkLunaris(AbortSignal.timeout(timeoutMs)),
}, timeoutMs);
return Response.json(
{ ...result, deploymentId },
{ status: result.status === "ready" ? 200 : 503, headers: { "Cache-Control": "no-store" } },
);
}