polly-ts
v0.1.0
Published
All-in-one Polly-TS bundle with core policies and integrations
Maintainers
Readme
polly-ts
All-in-one Polly-TS bundle with core policies and integrations.
Installation
npm install polly-ts
# or
pnpm add polly-tsUsage
Named exports from core:
import { RetryPolicy, CircuitBreakerPolicy, pipeline } from 'polly-ts';
const retry = new RetryPolicy({ maxAttempts: 3 });
const breaker = new CircuitBreakerPolicy({ failureThreshold: 5 });
const strategy = pipeline(breaker, retry);Namespaced access for integrations:
import express from 'express';
import { Core, Http, Express } from 'polly-ts';
const retry = new Core.RetryPolicy({ maxAttempts: 3 });
const breaker = new Core.CircuitBreakerPolicy({ failureThreshold: 5 });
const resilientFetch = Http.pollyFetch(retry);
const app = express();
app.get('/data', Express.polly(breaker), async (_req, res) => {
res.json({ ok: true });
});