Skip to main content

createWorkerPipeline

Creates a request pipeline inside the worker using pure-function interceptors. No Angular DI, no DOM access — just (req, next) => Promise.

TypeScriptexample.ts
import { createWorkerPipeline } from '@angular-helpers/worker-http/interceptors'

# Methods

MethodSignatureReturnsDescription
createWorkerPipelinecreateWorkerPipeline(interceptors: WorkerInterceptorFn[]): WorkerRequestHandlerWorkerRequestHandlerCreates a request handler that runs the interceptor chain before calling fetch().
retryInterceptorretryInterceptor(config?: RetryConfig): WorkerInterceptorFnWorkerInterceptorFnRetries failed requests with exponential backoff. Respects Retry-After header.
cacheInterceptorcacheInterceptor(config?: CacheConfig): WorkerInterceptorFnWorkerInterceptorFnIn-worker response cache with configurable TTL and max entries. Per-factory state.
hmacSigningInterceptorhmacSigningInterceptor(config: HmacSigningConfig): WorkerInterceptorFnWorkerInterceptorFnSigns outgoing requests with HMAC-SHA256/384/512. CryptoKey imported once and reused.
loggingInterceptorloggingInterceptor(config?: LoggingConfig): WorkerInterceptorFnWorkerInterceptorFnLogs request/response. Logger exceptions are swallowed — never interrupts pipeline.
rateLimitInterceptorrateLimitInterceptor(config?: RateLimitConfig): WorkerInterceptorFnWorkerInterceptorFnClient-side sliding-window rate limiter. Throws { status: 429 } when exceeded.
contentIntegrityInterceptorcontentIntegrityInterceptor(config?: IntegrityConfig): WorkerInterceptorFnWorkerInterceptorFnVerifies SHA-256 hash of response body against server-provided header.
composeInterceptorscomposeInterceptors(...fns: WorkerInterceptorFn[]): WorkerInterceptorFnWorkerInterceptorFnComposes multiple interceptors into a single interceptor function.
offlineCacheInterceptorofflineCacheInterceptor(config?: OfflineCacheConfig): WorkerInterceptorFnWorkerInterceptorFnOffline Cache interceptor using native Cache API in the Web Worker. Supports "network-first" and "cache-first" (stale-while-revalidate) strategies. Caches only GET requests and supports cache bypass headers.
offlineSyncQueueInterceptorofflineSyncQueueInterceptor(config?: OfflineSyncConfig): WorkerInterceptorFnWorkerInterceptorFnChronological (FIFO) mutation sync queue. Intercepts POST, PUT, PATCH, and DELETE requests when offline, stores them in IndexedDB, and returns a synthetic 202 Accepted. Replays them on reconnection.
LCP N/A
CLS N/A
INP N/A