From 6c945dcbf4bdd3a0843a98d97c09f042e433c3d3 Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Tue, 16 Jun 2026 22:58:17 +0700 Subject: [PATCH] feat: add API test page at /test endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- public/test-api.html | 363 +++++++++++++++++++++++++++++++++++++++++++ src/index.ts | 8 + 2 files changed, 371 insertions(+) create mode 100644 public/test-api.html diff --git a/public/test-api.html b/public/test-api.html new file mode 100644 index 0000000..4188be1 --- /dev/null +++ b/public/test-api.html @@ -0,0 +1,363 @@ + + + + + + Edge Proxy — API Test + + + +
+

Edge Proxy Relay — API Test

+

Test all proxy endpoints from the browser

+ + +
+
+ AUTH API Key + +
+
+ +
+ + +
+
+
+ + +
+
+ GET /health + +
+
+ + +
+
+ + +
+
+ GET /v1/models + +
+
+ + +
+
+ + +
+
+ POST /v1/chat/completions + +
+
+ + + + + +
+ +
+
+ + +
+
+ POST /v1/messages (Anthropic) + +
+
+ + + + + + + +
+ +
+
+ + +
+
+ RELAY Generic HTTP Relay + +
+
+ + + + + + + + +
+ +
+
+ +
+
+ + + + diff --git a/src/index.ts b/src/index.ts index f78191a..ad2fe94 100644 --- a/src/index.ts +++ b/src/index.ts @@ -461,6 +461,14 @@ const server: Server = Bun.serve({ // 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();