
Security News
pnpm 11.5 Adds Support for Recognizing npm Staged Publishes
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.
@fortify-ts/middleware
Advanced tools
Middleware composition chain for @fortify-ts resilience patterns
Middleware chain for composing resilience patterns in Fortify-TS.
npm install @fortify-ts/middleware
# or
pnpm add @fortify-ts/middleware
import { Chain } from '@fortify-ts/middleware';
import { CircuitBreaker } from '@fortify-ts/circuit-breaker';
import { Retry } from '@fortify-ts/retry';
import { Timeout } from '@fortify-ts/timeout';
const circuitBreaker = new CircuitBreaker({ maxFailures: 5 });
const retry = new Retry({ maxAttempts: 3 });
const timeout = new Timeout({ defaultTimeout: 5000 });
const chain = new Chain<Response>()
.withCircuitBreaker(circuitBreaker)
.withRetry(retry)
.withTimeout(timeout);
const result = await chain.execute(async (signal) => {
return fetch('/api/data', { signal });
});
import { Chain } from '@fortify-ts/middleware';
import { Bulkhead } from '@fortify-ts/bulkhead';
import { RateLimiter } from '@fortify-ts/rate-limit';
import { Timeout } from '@fortify-ts/timeout';
import { CircuitBreaker } from '@fortify-ts/circuit-breaker';
import { Retry } from '@fortify-ts/retry';
import { Fallback } from '@fortify-ts/fallback';
const chain = new Chain<Response>()
.withBulkhead(bulkhead) // 1st: Limit concurrency
.withRateLimit(rateLimiter, key) // 2nd: Rate limiting
.withTimeout(timeout, 5000) // 3rd: Timeout
.withCircuitBreaker(circuitBreaker) // 4th: Circuit breaker
.withRetry(retry) // 5th: Retry
.withFallback(fallback); // 6th: Fallback (innermost)
const result = await chain.execute(operation);
import { Chain, type Middleware } from '@fortify-ts/middleware';
// Custom logging middleware
const loggingMiddleware: Middleware<Response> = (next) => async (signal) => {
console.log('Starting operation');
const start = Date.now();
try {
const result = await next(signal);
console.log(`Completed in ${Date.now() - start}ms`);
return result;
} catch (error) {
console.log(`Failed in ${Date.now() - start}ms`);
throw error;
}
};
const chain = new Chain<Response>()
.use(loggingMiddleware)
.withRetry(retry);
Middleware executes from first added (outermost) to last added (innermost):
Request Flow:
Bulkhead → RateLimit → Timeout → CircuitBreaker → Retry → Fallback → Operation
Response Flow:
Operation → Fallback → Retry → CircuitBreaker → Timeout → RateLimit → Bulkhead
| Method | Description |
|---|---|
withCircuitBreaker(cb) | Add circuit breaker |
withRetry(retry) | Add retry |
withTimeout(timeout, duration?) | Add timeout |
withRateLimit(rl, key?) | Add rate limiting |
withBulkhead(bh) | Add bulkhead |
withFallback(fb) | Add fallback |
use(middleware) | Add custom middleware |
execute(operation, signal?) | Execute chain |
MIT
FAQs
Middleware composition chain for @fortify-ts resilience patterns
We found that @fortify-ts/middleware demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.