Rest Pipeline JS
Flexible, modular pipeline orchestrator for REST APIs — sequential and parallel stages, retry with backoff, response caching, rate limiting, auth provider, stream stages (SSE / AsyncIterable), plugin system, and Vue / React integrations — all with a single dependency (axios).
Features
createRestClient()— full-featured HTTP client built on top of axios: retry with exponential backoff andRetry-Aftersupport, response caching with a pluggableCacheStorebackend (incl. targetedinvalidateCache()), rate limiting (concurrency + req/interval) with a pluggable distributedRateLimiterStore, circuit breaker with a pluggable distributedCircuitBreakerStore, auth provider with automatic 401 refresh and optional token caching, request cancellation by key, custom HTTP adapters- Request tracing — W3C
traceparentheader generation plus aTracingProviderhook (duck-typed against OpenTelemetry'sSpanAPI) for wiring in a real tracing backend - Idempotency keys —
Idempotency-Keyheader on mutating requests, manual or auto-generated per logical request across retry attempts - Offline queue — queue mutating requests made while offline and replay them (same idempotency key on every attempt) once back online; pluggable persistence,
isOnline/onOnlineChangefor non-browser environments PipelineOrchestrator— sequential and parallel stage execution; each stage hascondition,before,request,after,validateInput,validateOutput,errorHandlerhooks (all receive the pipeline'sAbortSignal);sharedDatapool shared across all stages- Error recovery —
errorHandlercan returnrecoverStep(data)to turn a failed stage back into a successful one and keep the pipeline going, instead of only transforming the error - Global middleware —
beforeEach/afterEach/onErrorhooks that apply to every stage without modifying individual configs - Parallel groups — multiple stages run concurrently via
Promise.all, or through a bounded pool viaconcurrency; single failure stops the group - Pause / Resume / Abort —
pause()waits after the current stage;resume()continues;abort()cancels the current HTTP request and propagates itsAbortSignalinto every stage hook so customrequest/before/afterfunctions can cancel their own work too - Export / Import state — serialize
stageResults+ logs to a plain object; restore on the next page load - Stream stages —
stream: async function*for SSE / anyAsyncIterable;onChunkcallback in real time; abort-aware - WebSocket stages — a stage over a persistent connection (
onOpen/onMessage/onClose/onError,closeOn); pluggablecreateWebSocket(defaults toglobalThis.WebSocket) for Node <22/edge runtimes - Pipeline metrics & run correlation —
onPipelineStart,onPipelineEnd,onStepDurationcallbacks, plus arunId(also ongetRunId(), log entries, and step events) shared by every callback/event from the same run createPipeline()/pipe()builder — short factory and fluent builder API for common patterns; in TypeScript,pipe().step()chains inferprev's type from the previous step automaticallyvalidatePipelineConfig()— catch duplicate keys, empty keys, type errors before runtime- Plugin system — install reusable behavior (logging, analytics, etc.); cleanup via
destroy() - Persist adapter — pluggable save/load interface; auto-save after each stage
- Log sanitization — mask sensitive headers (
authorization,x-api-key,cookie, …) in metrics callbacks, on by default - Vue integration —
usePipelineRunVue,usePipelineProgressVue, and more (import fromrest-pipeline-js/vue) - React integration —
usePipelineRunReact,usePipelineProgressReact, and more (import fromrest-pipeline-js/react) paginate()/paginateAll()/flattenPages()— iterate a paginated API (cursor- or offset/limit-based) as anAsyncGenerator<T[]>, standalone or as aStreamStageConfigsourcecreateMockAdapter()(separaterest-pipeline-js/testingentry point) — route-basedHttpAdapterfor testing code that uses this package without a real backend, with call history and sequenced responses for exercising retry- Tree-shakeable —
sideEffects: false; Vue and React entry points are code-split