A middleware engine and a reactive pipeline
Two complementary paradigms for handling data flow in TypeScript — with full type inference and zero runtime dependencies.
Middleware Engine
Type-safe, Koa-style middleware composition with shared context and automatic error propagation.
Reactive Pipeline
Functional pipe composition with early exit, context injection and up to 10 typed steps.
Monad Integration
Compose Either, Maybe and Validation from monet, fp-ts and purify-ts directly inside a pipe.
Built for speed
Lazy evaluation, direct function composition and WeakMap-based bookkeeping for minimal overhead.
Quick look
Compose transformations with pipe:
import { pipe } from '@hyperse/pipeline';
const result = await pipe(
() => 123,
(n) => n + 1
)();
// result => 124Or build an ordered middleware chain with Pipeline:
import { Pipeline } from '@hyperse/pipeline';
const engine = new Pipeline<{ logs: string[] }>(async (ctx, next) => {
ctx.logs.push('first');
await next();
});
engine.use(async (ctx, next) => {
ctx.logs.push('second');
await next();
});