Add health check API route

Expose GET /health that returns JSON {status, timestamp}. Returns 200 on success
and 500 on error. Disable prerender for the endpoint.
This commit is contained in:
badblocks 2026-01-09 10:21:28 -08:00
parent bdf4f9a051
commit d5a7887ad2
No known key found for this signature in database

24
src/pages/health.ts Normal file
View file

@ -0,0 +1,24 @@
import type { APIRoute } from "astro";
export const prerender = false;
export const GET: APIRoute = async () => {
try {
return new Response(
JSON.stringify({
status: "pass",
timestamp: new Date().toISOString(),
}),
{
status: 200,
},
);
} catch {
return new Response(
JSON.stringify({
status: "fail",
timestamp: new Date().toISOString(),
}),
{ status: 500 },
);
}
};