generateUrl

View as MarkdownOpen in Claude

Generate the platform-specific invocation URL for a deployed function. Uses environment variables as defaults, with optional overrides.

Parameters

opts
object

Optional URL generation overrides.

opts.region
string

Cloud region override. Defaults to AWS_REGION or FUNCTION_REGION env var.

opts.projectId
string

GCP project ID override. Defaults to GCLOUD_PROJECT env var.

opts.functionName
string

Function name override. Defaults to AWS_LAMBDA_FUNCTION_NAME env var or "agent".

opts.stage
string

API Gateway stage override (Lambda only). Defaults to "prod".

opts.apiId
string

API Gateway ID override (Lambda only). Defaults to "API_ID".

Returns

string — The constructed URL string.

Example

1import { ServerlessAdapter } from '@signalwire/sdk';
2
3const adapter = new ServerlessAdapter('gcf');
4const url = adapter.generateUrl({
5 projectId: 'my-project',
6 region: 'us-central1',
7 functionName: 'my-agent',
8});
9console.log(url);
10// "https://us-central1-my-project.cloudfunctions.net/my-agent"