Skip to content

API reference

Everything pipeway exports, across three packages.

pipeway

The core. A pipeline builder and the constructors for its results.

ExportKindSummary
pipe(options?)functionCreate a pipeline.
.use(step)methodAdd a step (guard); enriches the typed context.
.map(fn)methodPre-handler context transform.
.catch(catcher)methodException filter (@Catch equivalent).
.serialize(fn)methodPost-handler JSON body filter (strip fields).
.transform(fn)methodPost-handler Response interceptor.
.handle(handler)methodTerminate the pipeline into a handler.
.json(handler, status?)methodTerminate, serializing values with a default status.
ok(extra)functionA step that succeeds, adding extra to context.
fail(response)functionA step that short-circuits with a Response.
success(value)functionA successful domain Result.
failure(error)functionA failed domain Result.

Types: Step, BaseCtx, StepResult, PipeOptions, Handler, CompiledHandler, Result, ResultMapper.

pipeway-steps

Generic, framework-agnostic Standard Schema steps (Zod / Valibot / ArkType).

ExportSummary
body(schema)Validate the JSON body → typed ctx.body.
query(schema)Validate the search params → typed ctx.query.

pipeway-adapter-node

ExportSummary
toNode(handler)Run a pipeway handler as Express/Node middleware.

pipeway-client

A portable, Result-first REST client (optional Standard Schema validation).

ExportSummary
createClient(config)Create a typed get/post/… client.
unwrap(result)ClientResult<T>T (throws on failure) for React Query / SWR.

No pipeway-specific React hooks: use TanStack Query / SWR with unwrap. pipeway types and validates the wire; your data library keeps caching.

pipeway-next

A typed pipeline for Next.js server actions.

ExportSummary
action(options?)Build a server-action pipeline → ActionResult.
input(schema)Validate the action argument (Standard Schema).

Mental model

pipe(options)
  .use(stepA)        // guard → ctx: BaseCtx & A
  .use(stepB)        // guard → ctx: BaseCtx & A & B  (B may require A — enforced by types)
  .map(fn)           // pre-handler ctx transform
  .catch(filter)     // exception filter (@Catch)
  .serialize(fn)     // post-handler JSON body filter (strip fields)
  .transform(fn)     // post-handler Response interceptor
  .handle(handler)   // → (req: Request, params) => Promise<Response>

Execution order: steps → maps → handler → serializers → transforms, with catch filters wrapping the whole run.

A step returns ok(extra) (continue, merge extra into context) or fail(response) (stop, return that Response). The handler returns a value (serialized to JSON), a Response, or a domain Result (mapped via onResult).

Released under the MIT License.