Skip to navigation

Start the HTTP or HTTPS service. The service uses HTTPS when SSL is fully configured, either through the ssl constructor option or the sslCert and sslKey arguments.

When SWAIG_CLI_MODE=true is set in the environment, the call is a no-op so you can inspect configuration without binding a port.

Parameters

host
stringDefaults to 0.0.0.0

Bind address.

port
number

Port override. Defaults to the service’s port.

sslCert
string

Path to the SSL certificate file. Overrides the ssl constructor option when passed together with sslKey.

sslKey
string

Path to the SSL key file.

Returns

Promise<void> — resolves once the server has begun listening.

Throws an Error if no basic-auth credentials are configured: the basicAuth option, the config file’s security.auth.basic, or SWML_BASIC_AUTH_USER and SWML_BASIC_AUTH_PASSWORD.

Example

import { WebService } from '@signalwire/sdk';
const web = new WebService({
directories: { '/audio': './public/audio' },
basicAuth: ['audio', process.env['AUDIO_PASSWORD'] ?? ''],
});
await web.start('127.0.0.1', 8080);