Skip to content

Function: parseBusUrl()

Makaio Framework


Makaio Framework / bus-core / 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/bus with 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, returns port: undefined so protocol defaults (443 for wss://) are respected

string | undefined

The value of MAKAIO_BUS_URL environment variable (or undefined)

BusUrlConfig

Parsed configuration with href, port, and isDefault flag

// No env var - local development
const config = parseBusUrl(undefined);
// { href: 'ws://localhost:6252/bus', port: 6252, isDefault: true }
// Production with explicit port
const config = parseBusUrl('wss://bus.example.com:9000/bus');
// { href: 'wss://bus.example.com:9000/bus', port: 9000, isDefault: false }
// Production with protocol default port
const config = parseBusUrl('wss://bus.example.com/bus');
// { href: 'wss://bus.example.com/bus', port: undefined, isDefault: false }