serve
Start the HTTP server that serves the SWML document.
Returns immediately when SWAIG_CLI_MODE=true is set, so the CLI testing
tool can load the service without opening a port.
serve() starts a @hono/node-server instance that runs until
explicitly stopped. For embedding into an existing application, use
asRouter() to get a mountable Hono sub-app instead.
serve() accepts two call shapes: the positional (host, port, opts) form, or a
single options object as the first argument.
Parameters
hostOrOpts
Either a host string (positional form) or a single options object with
host, port, sslCert, sslKey, sslEnabled, and domain fields. When an
options object is passed, its port takes precedence over the positional port,
and opts is ignored.
host
Positional form: hostname to bind to. Defaults to the host passed to the constructor, or
"0.0.0.0".
port
Port number to listen on. Defaults to the port passed to the constructor,
which itself falls back to the PORT environment variable or 3000.
opts
Optional SSL/TLS overrides. Each field falls back to the matching value on the service instance.
opts.sslCert
Path to the SSL certificate file. When both sslCert and sslKey are
resolved and sslEnabled is true, the server runs over HTTPS.
opts.sslKey
Path to the SSL private key file.
opts.sslEnabled
Override whether SSL/HTTPS is enabled for this run.
opts.domain
Domain name associated with the SSL certificate.
Returns
Promise<void> — resolves once the listener is bound.