feat: per-route body limits, custom error rendering, OpenAPI generation
CI / build (push) Has been cancelled
CI / build (push) Has been cancelled
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>
This commit is contained in:
19 files changed
+811
-100
No files matched your search
@@ -15,12 +15,14 @@ const app = createApp(options);
|
||||
| `plugins` | `Plugin[]` | `[]` | plugins, each limited to `bus.on` + `scope.add` ([plugins](/guides/plugins/)) |
|
||||
| `limits` | `RequestLimits` | see below | body-size and timeout ceilings |
|
||||
| `devGraph` | `boolean` | `false` | mount `GET /__graph__` ([introspection](/guides/introspection/)) |
|
||||
| `devOpenapi` | `boolean` | `false` | mount `GET /__openapi__` serving the [OpenAPI](/guides/openapi/) document |
|
||||
| `overrides` | `Record<string, unknown>` | — | swap any node by token ([testing](/guides/testing/)) |
|
||||
| `tls` | `TlsOptions` | — | serve over https/wss |
|
||||
| `trustProxy` | `boolean` | `false` | honor `X-Forwarded-*` for `ctx.protocol` / `ctx.ip` |
|
||||
| `security` | `boolean \| SecurityOptions` | `true` | secure-by-default headers ([security](/guides/security/)) |
|
||||
| `cors` | `CorsOptions` | — | CORS handling |
|
||||
| `bodyDuplicates` | `'array' \| 'last'` | `'last'` | policy for repeated form fields |
|
||||
| `onError` | `ErrorRenderer` | — | render errors your way ([error handling](/guides/errors/)); returns a response or `undefined` to fall back to JSON |
|
||||
| `mesh` | `MeshConfig` | — | distributed DI — **requires `experimental: true`** ([mesh](/guides/mesh/)) |
|
||||
| `experimental` | `boolean` | `false` | opt in to alpha features (currently gates `mesh`) |
|
||||
|
||||
@@ -62,6 +64,7 @@ const app = createApp(options);
|
||||
| `explain(route)` | `Explain` | the chain annotated with each node's needs/provides |
|
||||
| `graph()` | `GraphView` | the full node + route graph |
|
||||
| `toMermaid()` / `toDOT()` | `string` | render the graph |
|
||||
| `openapi(info?)` | `OpenApiDoc` | structural OpenAPI 3.1 document ([details](/guides/openapi/)) |
|
||||
| `degraded()` | `string[]` | optional providers running degraded (empty until `listen()`) |
|
||||
| `bus` | `Bus` | lifecycle + request event bus |
|
||||
|
||||
|
||||
Reference in new issue
Block a user