docs: serveDeno + app.upgrade — WebSocket on Deno

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-07-09 17:27:26 -05:00
1 parent f85b39c2c3
commit 47b7bf5f24
2 files changed
+31 -3

No files matched your search

+2
View File
@@ -11,6 +11,8 @@ green-tea uses calendar versioning: `YY.MM.PATCH`.
- **`app.fetch(request): Promise<Response>`** — a Web-Standards handler so the
same app runs HTTP and SSE on Deno/Bun/edge runtimes via the Fetch API
(WebSocket and mesh remain Node-only).
- **Deno adapter** (`@green-tea/core/deno`): `serveDeno(app)` runs HTTP + SSE + WebSocket on Deno.
- **`app.upgrade(request, socket)`**: neutral WebSocket entry point for non-Node runtimes, built on a shared `WsSocket` capability. WebSocket logic is now runtime-agnostic (`src/http/ws-core.ts`).
### Changed
- App-scope providers now boot exactly once (memoized): a second `app.listen()`
+29 -3
View File
@@ -25,10 +25,36 @@ export default { fetch: app.fetch };
**Node is the reference implementation** — every runtime returns the same status, headers,
and body for the same request (enforced by a parity test suite).
**Not yet on non-Node runtimes:** WebSocket (`@Ws`) and mesh — Node-only for now; cross-runtime
WebSocket is on the roadmap. `app.listen()` and TLS are Node-only; on Deno/Bun/edge you get
`app.fetch`.
**Not yet on Bun/edge runtimes:** WebSocket (`@Ws`) and mesh — still Node-only there; Deno now
has WebSocket support via `serveDeno` (see below). `app.listen()` and TLS remain Node-only; on
Deno/Bun/edge you get `app.fetch`.
**Body-size enforcement differs slightly:** on `app.fetch`, an oversized body is read in full
before the `413` is returned, whereas Node aborts mid-stream once the limit is hit — so on
non-Node runtimes, also bound request size at the platform/runtime layer.
## WebSocket on Deno
`app.fetch` covers HTTP + SSE on every runtime. WebSocket needs a runtime-specific
upgrade, so Deno gets a dedicated adapter at `@green-tea/core/deno`:
```ts
import { createApp } from '@green-tea/core';
import { serveDeno } from '@green-tea/core/deno';
const app = createApp({ modules: [ChatModule] });
// HTTP + SSE via app.fetch, WebSocket via Deno.upgradeWebSocket — one call:
serveDeno(app, { port: 8000 });
```
`serveDeno` routes normal requests through `app.fetch` and WebSocket upgrades through
`app.upgrade` — the same graph, the same `@Ws` handlers, the same rooms/channels you
run on Node. Behaviour matches the Node reference.
**Advanced:** `app.upgrade(request, socket)` is the neutral primitive `serveDeno` uses.
Any runtime can build a `WsSocket` capability (`inbound`, `abort`, `isOpen`, `send`,
`close`, `terminate`) and drive the graph — this is how Bun and edge support will land.
**Still Node-only:** `app.listen()`, TLS, per-request timeouts, and mesh. On Deno you
get `app.fetch` + `serveDeno`.