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,58 @@
---
title: Plugins & observability
description: "Extending the app safely via bus.on and scope.add."
---
A plugin is a function that receives the app's API at boot. It gets exactly two
capabilities: **observe** the running system through `bus.on(...)`, and **extend its own
scope** through `scope.add(...)`. That's the whole surface — and it's deliberately narrow.
```typescript
const logger = (api: any) => {
api.bus.on('request:step:enter', (p: any) => console.log(`→ ${p.name}`));
api.bus.on('stream:open', (p: any) => console.log(`stream open ${p.name}`));
api.bus.on('mesh:rpc:error', (p: any) => console.error('mesh rpc failed', p.error));
};
const app = createApp({ modules: [ApiModule], plugins: [logger] });
```
## Isolation is structural
A plugin can add steps and providers to **its own scope** via `scope.add(...)`. It
**cannot** reorder or delete another scope's steps. The graph — not a policy check —
enforces this: each scope owns its nodes, and a plugin has no handle on anyone else's.
There's no ordering hook to abuse and no step registry to mutate. If you want a plugin to
influence execution, it does so by contributing a node with declared `needs`/`provides`,
and the framework computes where that node lands.
:::note
Because execution is per-route (a route runs only the transitive closure of its handler's
`@needs`), a plugin step that should run on **every** route must produce nothing — add it
with `provides: []`. A step that produces no token has nothing to gate on, so the framework
runs it unconditionally. See [The graph](/concepts/the-graph/) for how the closure is
computed.
:::
## Lifecycle & request events
Subscribe to events on the `Bus` to observe boot, per-request execution, streaming, and
mesh activity without touching the pipeline itself:
```typescript
api.bus.on('boot:provider:ready', (p: any) => { /* ... */ });
api.bus.on('request:step:enter', (p: any) => { /* ... */ });
api.bus.on('request:step:exit', (p: any) => { /* ... */ });
```
The full event vocabulary:
- `boot:provider:*` — provider lifecycle during boot
- `request:step:*` — a step entering/exiting during a request
- `stream:open | stream:close | stream:error` — SSE/WS stream lifecycle
- `mesh:connect | mesh:disconnect | mesh:rpc:error` — mesh link and RPC activity
- `plugin:mounted` — a plugin finished mounting
Observation is read-only: handlers see the event payload but can't alter control flow. To
change behavior, contribute a node to your scope — see
[Dependency injection](/guides/dependency-injection/).