Skip to content

Commit

Permalink
update: add health endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Best-Codes committed Dec 14, 2024
1 parent 43c1bb6 commit 5bce5dd
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/server/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,36 @@ export async function handleRequest(
case "/":
return addCorsHeaders(serveFile("index.html", "text/html"));

case "/health":
if (req.method === "GET") {
try {
return addCorsHeaders(
new Response(
JSON.stringify({ status: "ok", application: "Chatter" }),
{
headers: { "Content-Type": "application/json" },
},
),
);
} catch (error) {
return addCorsHeaders(
new Response(
JSON.stringify({
success: false,
error: "Invalid request format",
}),
{
status: 400,
headers: { "Content-Type": "application/json" },
},
),
);
}
}
return addCorsHeaders(
new Response("Method not allowed", { status: 405 }),
);

case "/login":
if (req.method === "POST") {
try {
Expand Down

0 comments on commit 5bce5dd

Please sign in to comment.