From d5a7887ad224b15880e2a1d1f548e48468da78fc Mon Sep 17 00:00:00 2001 From: badbl0cks <4161747+badbl0cks@users.noreply.github.com> Date: Fri, 9 Jan 2026 10:21:28 -0800 Subject: [PATCH] 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. --- src/pages/health.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/pages/health.ts diff --git a/src/pages/health.ts b/src/pages/health.ts new file mode 100644 index 0000000..2924ec5 --- /dev/null +++ b/src/pages/health.ts @@ -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 }, + ); + } +};