zecomi
v0.3.0
Published
A simple, general-purpose and type-safe middleware library.
Readme
Introduction
zecomi's let's you define and compose middlewares in a type-safe fashion while making no assumptions about inputs, outputs or the type of computation being performed.
Usage
import { type Middleware, type Service, ServiceBuilder } from "zecomi";
class MyMiddleware<I, O> implements Middleware<I, O, I, O> {
public invoke(input: I, next: Service<I, O>): O {
// ...
const output = next.invoke(input);
// ...
return output;
}
}
const myService = ServiceBuilder.create<I, O>()
.use(new MyMiddleware())
// ...
.build({
invoke(input: I): O {
// business logic that generates outputs from inputs
},
});You can find more examples in the ./examples folder.
Changelog
View the changelog at CHANGELOG.md
