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

Function resolveEndpointUrl

packages/cli/src/commands/dev.ts:479–522  ·  view source on GitHub ↗
(apiUrl: string, apiKey: string, endpoint: ServerEndpoint)

Source from the content-addressed store, hash-verified

477}
478
479async function resolveEndpointUrl(apiUrl: string, apiKey: string, endpoint: ServerEndpoint) {
480 // use tunnel URL if provided
481 if (endpoint.type === "tunnel") {
482 return endpoint.url;
483 }
484
485 const apiURL = new URL(apiUrl);
486
487 // if the API is localhost and the hostname is localhost
488 if (apiURL.hostname === "localhost" && endpoint.hostname === "localhost") {
489 return `http://${endpoint.hostname}:${endpoint.port}`;
490 }
491
492 const triggerApi = new TriggerApi(apiKey, apiUrl);
493
494 const supportsTunneling = await triggerApi.supportsTunneling();
495
496 if (supportsTunneling) {
497 const tunnelSpinner = ora(`🚇 Creating Trigger.dev tunnel`).start();
498 const tunnelUrl = await createNativeTunnel(
499 endpoint.hostname,
500 endpoint.port,
501 endpoint.https,
502 triggerApi,
503 tunnelSpinner
504 );
505
506 if (tunnelUrl) {
507 tunnelSpinner.succeed(`🚇 Trigger.dev tunnel ready`);
508 }
509
510 return tunnelUrl;
511 } else {
512 // Setup tunnel
513 const tunnelSpinner = ora(`🚇 Creating tunnel`).start();
514 const tunnelUrl = await createNgrokTunnel(endpoint.hostname, endpoint.port, tunnelSpinner);
515
516 if (tunnelUrl) {
517 tunnelSpinner.succeed(`🚇 Created tunnel: ${tunnelUrl}`);
518 }
519
520 return tunnelUrl;
521 }
522}
523
524let yaltTunnel: YaltTunnel | null = null;
525

Callers 1

devCommandFunction · 0.85

Calls 4

supportsTunnelingMethod · 0.95
createNativeTunnelFunction · 0.85
createNgrokTunnelFunction · 0.85
startMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…