MCPcopy
hub / github.com/triggerdotdev/trigger.dev / fetch

Function fetch

apps/yalt/src/index.ts:14–40  ·  view source on GitHub ↗
(request: Request, env: Env, ctx: ExecutionContext)

Source from the content-addressed store, hash-verified

12
13export default {
14 async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
15 const url = new URL(request.url);
16 const route = routeUrl(url, env);
17
18 switch (route.type) {
19 case 'management': {
20 return handleManagementRequest(request, env, ctx);
21 }
22 case 'tunnel': {
23 console.log(`Handling tunnel request for ${route.name}`);
24
25 const id = await env.tunnelIds.get(route.name);
26
27 if (!id) {
28 return new Response('Not Found', { status: 404 });
29 }
30
31 const tunnel = env.connections.get(env.connections.idFromString(id));
32 return tunnel.fetch(request);
33 }
34 case 'not_found': {
35 return new Response('Not Found', { status: 404 });
36 }
37 }
38
39 return new Response('Not Found', { status: 404 });
40 },
41};
42
43type RouteDecision =

Callers 15

loaderFunction · 0.50
loaderFunction · 0.50
actionFunction · 0.50
safeFetchFunction · 0.50
#sendEventMethod · 0.50
callMethod · 0.50
#deliverPayloadMethod · 0.50
#getBearerTokenMethod · 0.50
#deliverWebhookMethod · 0.50
createMethod · 0.50
listMethod · 0.50
deleteMethod · 0.50

Calls 5

routeUrlFunction · 0.85
handleManagementRequestFunction · 0.85
fetchMethod · 0.80
logMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…