feat: add API test page at /test endpoint

- New public/test-api.html — browser-based test UI for all proxy endpoints
- Health check, model listing, Chat Completions (stream+non-stream),
  Anthropic Messages (stream+non-stream), and generic HTTP relay
- Server serves /test route from public/test-api.html

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
MythEclipse
2026-06-16 22:58:17 +07:00
co-authored by Claude
parent b09bca8def
commit 6c945dcbf4
2 changed files with 371 additions and 0 deletions
+8
View File
@@ -461,6 +461,14 @@ const server: Server<WSRelayData> = Bun.serve<WSRelayData>({
// Static routes
if (url.pathname === "/health") return handleHealth();
if (url.pathname === "/docs") return handleDocs();
if (url.pathname === "/test") {
const file = Bun.file("public/test-api.html");
const exists = await file.exists();
return new Response(exists ? file : "Not found", {
status: exists ? 200 : 404,
headers: { "Content-Type": "text/html; charset=utf-8" },
});
}
if (url.pathname === "/" && req.method === "GET" && !req.headers.get("x-relay-target"))
return handleIndex();