docs: honest README + quickstart, and a Starlight documentation site
CI / build (pull_request) Has been cancelled

Bring the README in line with what shipped and fill the gaps a technical
reader comparing frameworks needs: the busboy peer dep and dual build, a
Routing section with its limits, an explicit "bring your own auth" scope
note, why legacy decorators is a design choice (not laziness), and CalVer
beta versioning.

Add a full Astro Starlight docs site under website/ — getting started,
concepts, per-feature guides, and an API reference — migrated from the
tested quickstart so the examples stay accurate.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-07-07 12:02:17 -05:00
1 parent d6c5cee0ee
commit 654c0563fc
24 files changed
+8275 -7

No files matched your search

@@ -0,0 +1,70 @@
---
title: createApp options
description: "Every option accepted by createApp and every method on the App it returns."
---
```typescript
const app = createApp(options);
```
## Options
| Option | Type | Default | Meaning |
|---|---|---|---|
| `modules` | `Ctor[]` | — | the `@Module` classes to wire (required) |
| `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/)) |
| `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 |
| `mesh` | `MeshConfig` | — | distributed DI — **requires `experimental: true`** ([mesh](/guides/mesh/)) |
| `experimental` | `boolean` | `false` | opt in to alpha features (currently gates `mesh`) |
### `RequestLimits`
| Field | Default |
|---|---|
| `maxBodyBytes` | `1_000_000` (→ `413` when exceeded) |
| `requestTimeoutMs` | `30_000` |
| `headersTimeoutMs` | `10_000` |
| `keepAliveTimeoutMs` | `5_000` |
| `maxParts` | `1000` (multipart) |
### `TlsOptions`
`{ key, cert, ca?, passphrase? }` — `key`/`cert` are `Buffer | string`.
### `CorsOptions`
`{ origins, methods?, allowedHeaders?, exposedHeaders?, credentials?, maxAge? }`. `origins` is a string, array, `'*'`, or a `(origin) => boolean` predicate. `credentials: true` is never combined with `'*'`.
### `SecurityOptions`
`{ hsts?, frameOptions?, referrerPolicy?, noSniff?, dnsPrefetchControl?, csp? }`. HSTS is only emitted on secure connections. `csp` is opt-in.
### `MeshConfig`
`{ secret?, teapots?, timeoutMs? }` — `teapots` is `{ url, secret }[]`. See [Mesh](/guides/mesh/).
## The `App`
`createApp` returns an `App`:
| Member | Returns | Notes |
|---|---|---|
| `listen(port)` | `Promise<http.Server>` | boots providers, then serves |
| `close()` | `Promise<void>` | drains in-flight, closes streams + mesh links |
| `inspect(route)` | `InspectLine[]` | the provider/step/handler chain for a route |
| `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 |
| `degraded()` | `string[]` | optional providers running degraded (empty until `listen()`) |
| `bus` | `Bus` | lifecycle + request event bus |
:::note
On mesh apps, `graph` / `explain` / `inspect` / `degraded` are only available **after** `listen()` — the graph is finalized once remote scopes connect.
:::
@@ -0,0 +1,83 @@
---
title: Decorators
description: "Full reference for every class, method, and argument decorator."
---
Every decorator green-tea exports, grouped by where it applies. All require `experimentalDecorators: true` in your `tsconfig` — see [Why legacy decorators](/concepts/the-graph/#why-legacy-decorators).
## Structure
### `@Module(options)`
Marks a class as a module and records what it wires together.
```typescript
@Module({
mountpoint: '/api', // path prefix for this module's controllers (required)
providers: [Database], // app-scope @Provider classes
steps: [Authenticate], // request-scope @Step classes
controllers: [UserCtl], // @Route classes
})
class ApiModule {}
```
### `@Route(prefix)`
Marks a class as a controller; `prefix` is prepended to each route path.
## Providers & steps
### `@Provider(options)`
An app-scope value, built once at boot and cached, addressable by `provides`.
| Option | Type | Default | Meaning |
|---|---|---|---|
| `provides` | `string` | — | the token this provider produces (required) |
| `needs` | `string[]` | `[]` | tokens it depends on |
| `optional` | `boolean` | `false` | if it throws on boot, degrade instead of aborting ([details](/guides/dependency-injection/)) |
| `export` | `boolean` | `false` | expose over the mesh control channel ([mesh](/guides/mesh/)) |
### `@Step(options)`
A request-scope transform that merges keys into the context. Same options as `@Provider`.
### `@Transformer(fn)`
Method decorator. Turns a handler's return value into `{ status?, headers?, body }`. `JsonTransformer` is the default.
## Routes
Method decorators on a controller. All accept `(path, opts?)` where `opts = { export?: boolean, duplicates?: 'array' | 'last' }`.
| Decorator | Method | Transport |
|---|---|---|
| `@Get` `@Post` `@Put` `@Patch` `@Delete` | as named | buffered response |
| `@Sse` | GET | `text/event-stream` |
| `@Ws` | GET | WebSocket duplex |
| `@Stream` | GET | negotiated (SSE / ndjson / WS) |
```typescript
@Get('/ping', { export: true }) // exportable over mesh
@Post('/upload', { duplicates: 'array' }) // repeated form fields → arrays
```
See [Routing](/guides/routing/) for pattern matching and [Streaming](/guides/streaming/) for the transports.
## Arguments
A handler's signature declares exactly what it wants, in any order.
| Decorator | Injects | Forms |
|---|---|---|
| `@needs('user')` | a graph-produced value (boot-validated) | `('key')` |
| `@ctx()` | the whole accumulated context | `()` |
| `@param(...)` | route params | `()` · `('id')` · `('id', schema)` |
| `@query(...)` | parsed query string | `()` · `('q')` · `(['a','b'])` · `(schema)` |
| `@body(...)` | parsed body (JSON / urlencoded / multipart) | `()` · `('field')` · `(schema)` |
| `@headers(...)` | request headers (whole bag or picked) | `()` · `('authorization')` · `(['a','b'])` · `(schema)` |
| `@header('name')` | one request header (singular alias of `@headers`) | `('x-trace')` · `('x-count', schema)` |
| `@inbound()` | the incoming message stream (WebSocket) | `()` |
| `@abort()` | the request's `AbortSignal` | `()` |
Passing a [Standard Schema](/guides/validation/) validates and coerces the value before the handler sees it. Full details in [Argument decorators](/guides/arguments/).