MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / action

Function action

apps/webapp/app/routes/api.v1.tunnels.ts:25–69  ·  view source on GitHub ↗
({ request }: LoaderFunctionArgs)

Source from the content-addressed store, hash-verified

23}
24
25export async function action({ request }: LoaderFunctionArgs) {
26 // Next authenticate the request
27 const authenticationResult = await authenticateApiRequest(request);
28
29 if (!authenticationResult) {
30 return json({ error: "Invalid or Missing API key" }, { status: 401 });
31 }
32
33 if (authenticationResult.environment.type !== "DEVELOPMENT") {
34 return json({ error: "Tunneling is only supported in development" }, { status: 501 });
35 }
36
37 if (!env.TUNNEL_HOST || !env.TUNNEL_SECRET_KEY) {
38 return json({ error: "Tunneling is not supported" }, { status: 501 });
39 }
40
41 const yaltClient = new YaltApiClient(env.TUNNEL_HOST, env.TUNNEL_SECRET_KEY);
42
43 let tunnelId = authenticationResult.environment.tunnelId;
44
45 if (!tunnelId) {
46 try {
47 tunnelId = await yaltClient.createTunnel();
48
49 await prisma.runtimeEnvironment.update({
50 where: {
51 id: authenticationResult.environment.id,
52 },
53 data: {
54 tunnelId,
55 },
56 });
57 } catch (error) {
58 logger.error("Failed to create tunnel", { error });
59
60 return json({ error: "Failed to create tunnel" }, { status: 500 });
61 }
62 }
63
64 if (!tunnelId) {
65 return json({ error: "Failed to create tunnel" }, { status: 500 });
66 }
67
68 return json({ url: yaltClient.connectUrl(tunnelId) });
69}

Callers

nothing calls this directly

Calls 6

createTunnelMethod · 0.95
connectUrlMethod · 0.95
authenticateApiRequestFunction · 0.90
jsonFunction · 0.85
errorMethod · 0.65
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…