Skip to content

Configuration

Zlient is highly configurable at both the client level and the request level.

Client Options

Pass these to new HttpClient(options).

OptionTypeDescription
baseUrlsBaseUrlMapRequired. Map of service names to URLs. Must include default.
headersRecord<string, string>Default headers applied to every request.
authAuthProviderAuthentication strategy (see Auth Guide).
retryRetryStrategyGlobal retry configuration (see Error Handling).
timeout{ requestTimeoutMs: number }Global timeout for all requests.
interceptorsInterceptorsHooks for request/response lifecycle.
loggerLoggerLogger implementation.
metricsMetricsCollectorMetrics collector implementation.

BaseUrlMap

Zlient supports multiple services in one client instance.

typescript
const client = new HttpClient({
  baseUrls: {
    default: 'https://api.example.com',
    auth: 'https://auth.example.com',
    cdn: 'https://cdn.example.com'
  }
});

Using a specific service:

typescript
await getProfile({ baseUrlKey: 'auth' });

Request Options

Pass these as part of the argument object.

typescript
await endpoint({
  ...params,
  
  // Advanced options
  advanced: {
    // Override base URL (if supported by schema)
    baseUrlKey: 'cdn',
    // Skip authentication for this request
    skipAuth: true
  },
  
  // Merge these headers with default headers
  headers: { 'Cache-Control': 'no-cache' },
  
  // AbortSignal for cancellation
  signal: controller.signal,
  
  // Append query params dynamically
  query: { debug: 'true' }
});

Released under the MIT License.