run
Start the HTTP server like serve(), or handle a single serverless invocation.
run() handles the invocation instead of serving when opts.event is given, or when the
environment shows a serverless platform: any of AWS_LAMBDA_FUNCTION_NAME, _HANDLER,
FUNCTION_TARGET, FUNCTIONS_WORKER_RUNTIME, or GATEWAY_INTERFACE is set. Otherwise it calls
serve(opts).
Returns immediately when SWAIG_CLI_MODE=true is set, so the CLI testing tool can load the
agent without opening a port.
Parameters
opts
Optional server overrides and serverless invocation data.
opts.host
Host to bind the server to. Falls back to the constructor’s host option.
opts.port
Port to listen on. Falls back to the constructor’s port option.
opts.event
The platform’s invocation event. When set, run() handles this invocation instead of starting
a server.
opts.context
The platform’s invocation context, passed through with the event.
opts.platform
Serverless platform. Detected from the environment when omitted.
Returns
Promise<void | ServerlessResponse> — Resolves once the server is running, or with the
response for a serverless invocation.