alepha@docs:~/docs/reference/primitives$
cat $pipeline.md1 min read
#$pipeline
#Import
typescript
1import { $pipeline } from "alepha";
#Overview
Creates a pipeline primitive that composes middleware with a handler.
It makes a big function which runs all functions (middleware) inside use array before and after the handler function.
The middleware functions are applied in the order they are defined in the use array.
So PipelinePrimitive is also a base for primitives with handler which need some sort of plugins.
Use $pipeline for standalone composition outside host primitives ($action, $job, $page).
Host primitives extend PipelinePrimitive directly to get middleware support.
ts
1class OrderService {2 processOrder = $pipeline({3 use: [$lock({ name: "process-order" }), $retry({ max: 3 })],4 handler: async (orderId: string) => {5 return await this.orders.updateById(orderId, { status: "paid" });6 },7 });8}
#Options
| Option | Type | Required | Description |
|---|---|---|---|
use |
Middleware[] |
Yes | |
handler |
T |
Yes |