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
| Method | Signature | Returns | Description |
|---|---|---|---|
createWorkerPipeline | createWorkerPipeline(interceptors: WorkerInterceptorFn[]): WorkerRequestHandler | WorkerRequestHandler | Creates a request handler that runs the interceptor chain before calling fetch(). |
retryInterceptor | retryInterceptor(config?: RetryConfig): WorkerInterceptorFn | WorkerInterceptorFn | Retries failed requests with exponential backoff. Respects Retry-After header. |
cacheInterceptor | cacheInterceptor(config?: CacheConfig): WorkerInterceptorFn | WorkerInterceptorFn | In-worker response cache with configurable TTL and max entries. Per-factory state. |
hmacSigningInterceptor | hmacSigningInterceptor(config: HmacSigningConfig): WorkerInterceptorFn | WorkerInterceptorFn | Signs outgoing requests with HMAC-SHA256/384/512. CryptoKey imported once and reused. |
loggingInterceptor | loggingInterceptor(config?: LoggingConfig): WorkerInterceptorFn | WorkerInterceptorFn | Logs request/response. Logger exceptions are swallowed — never interrupts pipeline. |
rateLimitInterceptor | rateLimitInterceptor(config?: RateLimitConfig): WorkerInterceptorFn | WorkerInterceptorFn | Client-side sliding-window rate limiter. Throws { status: 429 } when exceeded. |
contentIntegrityInterceptor | contentIntegrityInterceptor(config?: IntegrityConfig): WorkerInterceptorFn | WorkerInterceptorFn | Verifies SHA-256 hash of response body against server-provided header. |
composeInterceptors | composeInterceptors(...fns: WorkerInterceptorFn[]): WorkerInterceptorFn | WorkerInterceptorFn | Composes multiple interceptors into a single interceptor function. |
offlineCacheInterceptor | offlineCacheInterceptor(config?: OfflineCacheConfig): WorkerInterceptorFn | WorkerInterceptorFn | Offline 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. |
offlineSyncQueueInterceptor | offlineSyncQueueInterceptor(config?: OfflineSyncConfig): WorkerInterceptorFn | WorkerInterceptorFn | Chronological (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. |