Function: parseBusUrl()
Makaio Framework / bus-core / parseBusUrl
Function: parseBusUrl()
Section titled “Function: parseBusUrl()”parseBusUrl(
envValue):BusUrlConfig
Defined in: ../../../packages/bus-core/src/utils/url-config.ts:64
Parses the bus URL from environment variable with correct default handling.
Key behaviors:
- No env var: Returns default
ws://localhost:6252/buswith explicit port 6252 - Env var with explicit port: Uses that port
- Env var without port (e.g.,
wss://bus.example.com/bus): Preserves URL as-is, returnsport: undefinedso protocol defaults (443 for wss://) are respected
Parameters
Section titled “Parameters”envValue
Section titled “envValue”string | undefined
The value of MAKAIO_BUS_URL environment variable (or undefined)
Returns
Section titled “Returns”Parsed configuration with href, port, and isDefault flag
Example
Section titled “Example”// No env var - local developmentconst config = parseBusUrl(undefined);// { href: 'ws://localhost:6252/bus', port: 6252, isDefault: true }
// Production with explicit portconst config = parseBusUrl('wss://bus.example.com:9000/bus');// { href: 'wss://bus.example.com:9000/bus', port: 9000, isDefault: false }
// Production with protocol default portconst config = parseBusUrl('wss://bus.example.com/bus');// { href: 'wss://bus.example.com/bus', port: undefined, isDefault: false }