Connectum API Reference / @connectum/interceptors / defaults / createDefaultInterceptors
Function: createDefaultInterceptors() ​
createDefaultInterceptors(
options?):Interceptor[]
Defined in: defaults.ts:162
Creates the default interceptor chain with the specified configuration.
The interceptor order is fixed and intentional:
- errorHandler - Normalize rejections from downstream
next(req)(outermost; enabled by default) - timeout - Enforce deadline before any processing (OPT-IN)
- bulkhead - Limit concurrency (OPT-IN)
- circuitBreaker - Prevent cascading failures (OPT-IN; wraps retry — an ultimate failure counts once, regardless of the number of retry attempts)
- retry - Retry transient failures with exponential backoff (OPT-IN)
- fallback - Graceful degradation (OPT-IN, requires handler)
- validation - @connectrpc/validate (enabled by default)
- serializer - JSON serialization (innermost, OPT-IN)
Resilience interceptors (2-5) are opt-in by design: the recommended path must not silently alter request behavior.
Parameters ​
options? ​
DefaultInterceptorOptions = {}
Configuration for each interceptor
Returns ​
Interceptor[]
Array of configured interceptors in the correct order
Example ​
typescript
import { createDefaultInterceptors } from '@connectum/interceptors';
// Defaults: errorHandler + validation only
const defaults = createDefaultInterceptors();
// Explicitly enable resilience where needed
const withResilience = createDefaultInterceptors({
timeout: { duration: 10000 },
bulkhead: true,
retry: { maxRetries: 3 },
});
// Enable fallback with handler
const withFallback = createDefaultInterceptors({
fallback: { handler: () => ({ data: [] }) },
});
// No interceptors: omit `interceptors` option in createServer()
// or pass `interceptors: []`