Skip to main content
zerotal

Documentation


Documentation / @zerotal/core / index / Pipeline

Class: Pipeline<T>

Defined in: pipeline/Pipeline.ts:32

Generic middleware pipeline: sends a payload through an ordered list of pipe classes and hands the final payload to a destination.

Pipes are resolved from the container when .via() is called; otherwise each is instantiated directly with new PipeClass().

Examples

const result = await Pipeline.send(ctx)
  .through([AuthMiddleware, ThrottleMiddleware])
  .via(container)           // optional — resolves pipes from container
  .then((ctx) => ctx.response);
// Run the chain and read the mutated payload back:
const finished = await Pipeline.send(ctx).through(pipes).via(container).thenReturn();
return finished.response;

Type Parameters

T

T

The payload type carried through the pipes (typically HttpContext).

Methods

send()

static send<T>(payload): Pipeline<T>

Defined in: pipeline/Pipeline.ts:42

Begin a pipeline carrying payload through the pipes added by through().

Type Parameters

T

T

Parameters

payload

T

Returns

Pipeline<T>


through()

through(pipes): this

Defined in: pipeline/Pipeline.ts:49

Set the ordered list of pipe classes the payload travels through.

Parameters

pipes

PipeClass<T>[]

Returns

this


via()

via(container): this

Defined in: pipeline/Pipeline.ts:55

Inject a container so pipes are resolved from it (supports @inject).

Parameters

container

Container

Returns

this


then()

then<R>(destination): Promise<R>

Defined in: pipeline/Pipeline.ts:66

Execute the pipeline and pass the final payload to destination. Returns whatever destination returns.

Type Parameters

R

R

Parameters

destination

(payload) => R | Promise<R>

Returns

Promise<R>


thenReturn()

thenReturn(): Promise<T>

Defined in: pipeline/Pipeline.ts:78

Execute the pipeline and return the final payload unchanged.

The pipeline mutates the payload in-place: every pipe shares the one payload (the request HttpContext), and the canonical Response is written to payload.response. Read it back from there.

Returns

Promise<T>