Installation
Requirements
The core package has no required peer dependencies — only axios (a regular dependency). Vue and React are optional peers, needed only if you import from the matching entry point (rest-pipeline-js/vue / rest-pipeline-js/react):
| Environment | Minimum version |
|---|---|
| Node.js | 18+ |
| Vue | 3.3+ (optional, for /vue) |
| React | 18+ (optional, for /react) |
| react-dom | 18+ (optional, for /react) |
Installation
npm install rest-pipeline-jsPeer dependencies for framework integrations:
# Vue
npm install vue@>=3.3
# React
npm install react@>=18 react-dom@>=18CDN usage
No bundler, no Node — a single <script> tag pulls in the core module (PipelineOrchestrator / createRestClient / everything under the core entry point, no Vue/React) with axios bundled in, so nothing else needs to be loaded separately. Built as a self-contained IIFE that exposes a window.RestPipeline global — a plain <script> tag, no CommonJS/AMD loader support:
<script src="https://unpkg.com/rest-pipeline-js/dist/umd/rest-pipeline.umd.min.js"></script>
<script>
const { createRestClient, PipelineOrchestrator } = RestPipeline
const client = createRestClient({ baseURL: 'https://api.example.com' })
const pipeline = new PipelineOrchestrator({
config: {
stages: [{ key: 'user', request: () => client.get('/me') }],
},
})
pipeline.run().then((result) => console.log(result))
</script>Pin a version for production use (rest-pipeline-js@2.1.0/dist/umd/...) — the unpinned URL above always resolves to the latest release. jsDelivr works the same way: https://cdn.jsdelivr.net/npm/rest-pipeline-js/dist/umd/rest-pipeline.umd.min.js.
An unminified build with a source map (rest-pipeline.umd.js) is also published, for debugging.
Quick start
import { createRestClient, PipelineOrchestrator } from 'rest-pipeline-js'
// 1. Create a REST client
const client = createRestClient({
baseURL: 'https://api.example.com',
retry: { attempts: 2, delayMs: 500, backoffMultiplier: 2 },
cache: { enabled: true, ttlMs: 60000 },
auth: {
getToken: async () => localStorage.getItem('token') ?? '',
onUnauthorized: async () => {
/* refresh token */
},
},
})
const res = await client.get('/users/1')
// 2. Run a pipeline
const orchestrator = new PipelineOrchestrator({
config: {
stages: [
{
key: 'fetchUser',
request: async ({ sharedData }) => client.get(`/users/${sharedData.userId}`),
},
{
key: 'processData',
request: async ({ prev }) => ({ ...prev.data, processed: true }),
},
],
},
sharedData: { userId: 42 },
})
const result = await orchestrator.run()
console.log(result.success, result.stageResults)