MCPcopy Create free account
hub / github.com/Improbable-AI/VisionProTeleop / fetch

Function fetch

infrastructure/signaling-server/src/index.ts:19–46  ·  view source on GitHub ↗
(request: Request, env: Env)

Source from the content-addressed store, hash-verified

17
18export default {
19 async fetch(request: Request, env: Env): Promise<Response> {
20 const url = new URL(request.url);
21
22 // Health check endpoint
23 if (url.pathname === "/health") {
24 return new Response(JSON.stringify({ status: "ok", timestamp: Date.now() }), {
25 headers: { "Content-Type": "application/json" }
26 });
27 }
28
29 // WebSocket upgrade for signaling
30 if (url.pathname === "/ws") {
31 const upgradeHeader = request.headers.get("Upgrade");
32 if (upgradeHeader !== "websocket") {
33 return new Response("Expected WebSocket", { status: 426 });
34 }
35
36 // Route to a singleton Durable Object that manages all rooms
37 const id = env.ROOMS.idFromName("global");
38 const room = env.ROOMS.get(id);
39 return room.fetch(request);
40 }
41
42 // Default response
43 return new Response("VisionProTeleop Signaling Server\n\nConnect via WebSocket at /ws", {
44 headers: { "Content-Type": "text/plain" }
45 });
46 }
47};
48
49// ============================================================================

Callers 1

generateIceServersMethod · 0.85

Calls 2

fetchMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected