Steps were executed by three separate hand-rolled loops: runPipeline (HTTP),
buildWsRoutes (ws) and resolveScope (mesh). Only the HTTP one emitted
request:step:enter/leave, so a logging plugin silently observed nothing on ws
routes — a gap in a documented public API, not just redundancy.
Route every transport through a single runSteps() so observability is uniform
by construction rather than by remembering to copy the emit calls.
Also fixes the plugins guide, which documented a request:step:exit event that
has never existed (the bus emits request:step:leave).
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Also fixes buildWsRoutes (app/index.ts) to read the pre-derived
protocol/ip off the neutral WsRequest instead of req.socket, which no
longer exists now that WsOpenCtx.req is WsRequest — without this every
real @Ws route throws on open() and the connection hangs.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
app.fetch's 413/400/501 body-acquisition failures were returned without
the injected security/CORS headers Node's writeHead patch always
applies, breaking byte-identical parity with the listen() path. Extract
computeInjected() (shared by handle() and buildFetch()) and merge it
into every error response, not just handle()'s outcomes.
Also, buildAppFetch captured `booted` by value at createApp() time, so
mesh apps (whose finalize() is deferred into listen()) had app.fetch
permanently throw even after a successful listen(). Read booted live
via a getter, mirroring explain()/graph()/inspect(), and lazily
build/cache the fetch handler on first call after boot.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Mermaid's static diagram overlaps badly as the graph grows. Replace the
/__graph__ HTML with an interactive Cytoscape.js + dagre viewer (both loaded
from a CDN, so no runtime dependency is added — the one-dep pitch holds).
Clicking a route lights up its real transitive slice and dims the rest;
clicking a provider/step shows its blast radius. Edges are colour-coded by
kind (needs vs feeds-endpoint), provider/step/endpoint nodes are visually
distinct, and nodes are draggable. toMermaid()/toDOT() and the text/plain
path are unchanged.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Three capabilities that share the same request/route metadata:
- **Per-route upload limits** — `@Post('/x', { maxBodyBytes, maxParts })`
overrides the server-wide `limits` for one route (falls back to the
global default), mirroring the existing per-route `duplicates`.
- **Custom error rendering** — `createApp({ onError })` takes over how any
error becomes a response (HTML, RFC 7807, content-negotiated), covering
the whole surface: handler/step throws, 404, 405, 413, 400. Returns a
response or undefined to fall back to the default JSON. Also wires the
previously-unused `HttpError` `body` field so `throw new HttpError(409,
'conflict', { code })` renders a structured payload. Default behavior is
unchanged when no hook is set.
- **OpenAPI 3.1** — `app.openapi(info?)` projects the route graph into a
structural spec (paths, methods, path/query/header params, request-body
presence, systematic error responses); opt-in `GET /__openapi__` via
`devOpenapi`. Body/response schemas stay generic (Standard Schema exposes
no JSON Schema) — the full `@Produce` mode is post-beta.
Docs: new error-handling and OpenAPI guides, plus reference updates.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
Restructure first: split the two oversized files by cohesion (http.ts 449
→ http/{router,request,stream,ws,server,types}; app.ts 556 → app/{types,
introspect,index}), rename cryptic locals, JSDoc the public API, and
extract helpers so no function exceeds the complexity gate (createApp
187 → <15, listen 113 → 6). Public import paths are unchanged (barrels).
On that structure, five features that close the biggest gaps vs
Express/Fastify/Nest for a comparable beta:
- routing: `:name*` catch-all, specificity precedence (static ▸ param ▸
catch-all, not registration order), and 405 + Allow when a path exists
under a different method (was 404)
- visible degradation: optional providers that fail boot are summarized on
listen() and queryable via app.degraded(), instead of a silent warn
- mesh is alpha — gated behind `experimental: true`; createApp throws if
`mesh` is configured without it
- multipart moves to the optional `busboy` peer dependency (clear 501 when
absent), keeping the core at one runtime dependency
- `@header('name')` as a singular alias of `@headers`
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>