detectPlatform

View as MarkdownOpen in Claude

Detect the serverless platform by inspecting well-known environment variables. Checks for AWS Lambda (AWS_LAMBDA_FUNCTION_NAME, _HANDLER), Google Cloud Functions (FUNCTION_TARGET, K_SERVICE), Azure Functions (FUNCTIONS_WORKER_RUNTIME, AZURE_FUNCTIONS_ENVIRONMENT), and CGI (GATEWAY_INTERFACE). Defaults to "lambda" if no match is found.

Parameters

None.

Returns

ServerlessPlatform — The detected platform identifier: "lambda", "gcf", "azure", or "cgi".

Example

1import { ServerlessAdapter } from '@signalwire/sdk';
2
3const adapter = new ServerlessAdapter();
4console.log(adapter.detectPlatform()); // "lambda"