docs(site): document matcha, stop contradicting the transport rule, drop Node-only
The streaming guide argued with itself: the table said a plain return streams by Accept while the section below it, added with the explicit-transport change, said that same return is a 500. The prose got swept, the table didn't. Getting started said green-tea targets Node — true when written, wrong since the Deno/Bun/edge adapters landed — and led with a manual install even though matcha scaffolds a live app in two commands. matcha had no page at all, so the CLI was invisible to anyone reading the docs. site: pointed at green-tea.dev, which is the marketing site's domain; the docs deploy to docs.green-tea.dev. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
6 files changed
+100
-7
No files matched your search
@@ -7,18 +7,17 @@ Most stacks treat "push data over time" as a bolt-on: Express reaches for a `ws`
|
||||
|
||||
green-tea has one model: an **`AsyncIterable`**. A handler that returns a sequence of values over time *is* a stream — the same shape you'd return from any function. You **declare the mode** with a decorator; the framework handles framing, backpressure, cleanup, and disconnects.
|
||||
|
||||
## One primitive, four modes
|
||||
## One primitive, three modes
|
||||
|
||||
| Declare | Direction | Transport | Reach for it when |
|
||||
|---|---|---|---|
|
||||
| `@Sse` | server → client | `text/event-stream` | live updates to a browser (`EventSource`) |
|
||||
| `@Ws` | duplex | WebSocket | chat, collaboration — anything two-way |
|
||||
| `@Stream` | negotiated | SSE / ndjson / WS, picked from the client's `Accept` / `Upgrade` | one handler, the client chooses |
|
||||
| *(plain return)* | server → client | SSE or ndjson by `Accept` | programmatic streaming over `fetch` |
|
||||
|
||||
The primitive never changes — it's always an `AsyncIterable`. What changes is **direction and framing**, and you declare which. That's the difference between each iterable green-tea hands you:
|
||||
|
||||
- **`@Sse` / plain return** — you return **one** iterable: the *outbound* stream. Each `yield` becomes an SSE event, or an ndjson line.
|
||||
- **`@Sse`** — you return **one** iterable: the *outbound* stream. Each `yield` becomes an SSE event, or an ndjson line.
|
||||
- **`@Ws` (duplex)** — **two** iterables. `@inbound()` gives you the client's *incoming* messages to consume; the one you **return** is the *outbound* stream to the client. `@abort()` hands you an `AbortSignal` for teardown.
|
||||
- **`@Stream`** — you write the handler once; the client's request decides whether it arrives as SSE, ndjson, or a WebSocket. No branching in your code.
|
||||
|
||||
|
||||
Reference in new issue
Block a user