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:
parent
bdf4f9a051
commit
d5a7887ad2
1 changed files with 24 additions and 0 deletions
24
src/pages/health.ts
Normal file
24
src/pages/health.ts
Normal 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 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue