API reference
Everything pipeway exports, across three packages.
pipeway
The core. A pipeline builder and the constructors for its results.
| Export | Kind | Summary |
|---|---|---|
pipe(options?) | function | Create a pipeline. |
.use(step) | method | Add a step (guard); enriches the typed context. |
.map(fn) | method | Pre-handler context transform. |
.catch(catcher) | method | Exception filter (@Catch equivalent). |
.serialize(fn) | method | Post-handler JSON body filter (strip fields). |
.transform(fn) | method | Post-handler Response interceptor. |
.handle(handler) | method | Terminate the pipeline into a handler. |
.json(handler, status?) | method | Terminate, serializing values with a default status. |
ok(extra) | function | A step that succeeds, adding extra to context. |
fail(response) | function | A step that short-circuits with a Response. |
success(value) | function | A successful domain Result. |
failure(error) | function | A failed domain Result. |
Types: Step, BaseCtx, StepResult, PipeOptions, Handler, CompiledHandler, Result, ResultMapper.
pipeway-steps
Generic, framework-agnostic Standard Schema steps (Zod / Valibot / ArkType).
| Export | Summary |
|---|---|
body(schema) | Validate the JSON body → typed ctx.body. |
query(schema) | Validate the search params → typed ctx.query. |
pipeway-adapter-node
| Export | Summary |
|---|---|
toNode(handler) | Run a pipeway handler as Express/Node middleware. |
pipeway-client
A portable, Result-first REST client (optional Standard Schema validation).
| Export | Summary |
|---|---|
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.
| Export | Summary |
|---|---|
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).