Commit Graph
351 Commits
Author SHA1 Message Date
chrnx 289ca5f8ff docs(views): @Html, templating, and static serving guide
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 14:50:06 -05:00
chrnx ad3a06f057 feat(views): zero-config static directory serving
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 14:42:20 -05:00
chrnx b8ebb9d04b feat(views): @Html string/file/template modes with boot validation
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 14:36:40 -05:00
chrnx e1a2c3253b feat(views): @Html decorator and metadata
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 14:31:12 -05:00
chrnx da5cc936a3 feat(views): built-in template engine + content-type map
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 14:26:57 -05:00
chrnx e54de8c1db Merge branch 'fix/dev-routes-on-fetch' into develop
CI / build (push) Has been cancelled
Serve /__graph__ + /__openapi__ over app.fetch so the dev tools (graph viewer,
OpenAPI) work on Deno/Bun/edge, not just the Node listen() path.
2026-07-10 00:10:56 -05:00
chrnx df13a62d93 fix(app): serve /__graph__ and /__openapi__ over app.fetch (dev tools on all runtimes)
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-10 00:10:54 -05:00
chrnx 6833293ccf Merge branch 'feature/runtime-edge-ws' into develop
CI / build (push) Has been cancelled
Step 4 runtime-agnostic: Edge / Cloudflare Workers + WebSocket.
- @green-tea/core/edge edgeHandler (HTTP+SSE+WS on workerd), real Miniflare test
- reuses the neutral WsSocket capability + app.upgrade (edge-only supplies a socket)
- lazy-load http/https so createApp is edge/workerd-safe (Node path identical)
- runtime-agnostic saga complete: Node + Deno + Bun + edge
2026-07-09 23:52:30 -05:00
chrnx cb4ecd6801 docs: edgeHandler — WebSocket on Cloudflare Workers / edge
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 23:45:27 -05:00
chrnx 70925035d7 fix(http): lazy-load http/https so createApp is edge/workerd-safe; drop test shim
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 23:40:28 -05:00
chrnx a4c9df9a74 test(edge): edgeHandler HTTP + WebSocket on real workerd via Miniflare
Boots the actual workerd engine locally (miniflare devDep, no CF account
needed) and round-trips HTTP (app.fetch) + WebSocket (WebSocketPair +
app.upgrade) through edgeHandler's real request path, mirroring the Deno/Bun
adapter tests' assertion shape.

workerd's nodejs_compat genuinely does not implement node:http/node:https
(confirmed in isolation against the real runtime; node:crypto, node:stream,
node:net, node:tls, node:events, node:util, node:buffer all load fine under
the same flags). The barrel statically imports them for the Node listen()
path even though edgeHandler never touches it, so the bundler stubs those
two modules at test-bundle time (inert createServer that throws if ever
called) purely to let the worker load — edgeHandler itself is untouched.
See project-docs/.superpowers/sdd/task-2-report.md for the full writeup and
the suggested core follow-up (lazy-defer those imports behind listen()).

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 23:34:19 -05:00
chrnx 9344cc7d43 feat(edge): edgeHandler adapter — HTTP+SSE+WS on Cloudflare Workers via /edge subpath
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 23:22:28 -05:00
chrnx 86c206d2c9 Merge branch 'feature/runtime-bun-ws' into develop
CI / build (push) Has been cancelled
Step 3 runtime-agnostic: Bun adapter + WebSocket.
- @green-tea/core/bun serveBun (HTTP+SSE+WS on Bun), real bun test
- reuses the neutral WsSocket capability + app.upgrade (zero core changes)
- open-deferred WsSocket build via ws.data; binary parity + ws error handler
2026-07-09 22:08:58 -05:00
chrnx 82824e5f6d fix(bun): add ws error handler for Node/Deno parity; hoist TextDecoder
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 22:00:23 -05:00
chrnx 3d21117a07 docs: serveBun — WebSocket on Bun
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 21:54:34 -05:00
chrnx 4351b41038 test(bun): serveBun HTTP + WebSocket integration
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 21:51:33 -05:00
chrnx fd6446f514 feat(bun): serveBun adapter — HTTP+SSE+WS on Bun via /bun subpath
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 21:44:46 -05:00
chrnx 8d3a4ca420 Merge branch 'feature/runtime-deno-ws' into develop
CI / build (push) Has been cancelled
Step 2 runtime-agnostic: Deno adapter + WebSocket capability.
- Neutral WS core (ws-core.ts) behind a WsSocket capability
- Node adapter rebuilt over it (behaviour byte-identical)
- app.upgrade(request, socket) neutral primitive
- @green-tea/core/deno serveDeno (HTTP+SSE+WS on Deno), real deno test
- docs + CHANGELOG
2026-07-09 17:39:55 -05:00
chrnx 4a6ef784ec fix(deno): decode binary ws frames to match Node; changelog ctx.req note
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 17:38:23 -05:00
chrnx 47b7bf5f24 docs: serveDeno + app.upgrade — WebSocket on Deno
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 17:27:26 -05:00
chrnx f85b39c2c3 test(deno): serveDeno HTTP + WebSocket integration
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 17:23:24 -05:00
chrnx e9357efb5c fix(deno): guard fire-and-forget app.upgrade against fatal unhandled rejection
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 17:17:20 -05:00
chrnx 12eccd941c feat(deno): serveDeno adapter — HTTP+SSE+WS on Deno via /deno subpath
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 17:11:00 -05:00
chrnx d72452d9b6 feat(app): app.upgrade — neutral WebSocket entry over the graph
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 17:04:38 -05:00
chrnx 7a8be39d57 refactor(ws): Node adapter builds WsSocket over the neutral core
Also fixes buildWsRoutes (app/index.ts) to read the pre-derived
protocol/ip off the neutral WsRequest instead of req.socket, which no
longer exists now that WsOpenCtx.req is WsRequest — without this every
real @Ws route throws on open() and the connection hangs.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 16:56:17 -05:00
chrnx 5e68d2de65 fix(ws): runtime-neutral close reason + registry removal on transport close
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 16:51:42 -05:00
chrnx 179a58f0e4 feat(ws): neutral runWsConnection core behind a WsSocket capability
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 16:44:59 -05:00
chrnx 0aab3ed123 feat(http): runtime-agnostic app.fetch (Web-Standards handler)
CI / build (push) Has been cancelled
Step 1 of runtime-agnostic: expose app.fetch(request): Promise<Response>,
reusing the pipeline core so the app runs on Deno.serve/Bun.serve/edge for
HTTP + SSE. Node app.listen path unchanged (truth grounding, parity-tested).
WebSocket + mesh remain Node-only (later steps).

Merges feature/runtime-agnostic-fetch (9 commits).

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 14:47:59 -05:00
chrnx 58853e8ba8 docs: changelog for app.fetch + provider memoization, runtimes body-size note
Record the app.fetch Web-Standards handler and the app-scope provider
memoization behaviour change in the changelog, and note on the runtimes
guide that app.fetch reads oversized bodies fully before rejecting them
(unlike Node's mid-stream abort) so non-Node deployments should also
bound request size at the platform layer.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 14:45:34 -05:00
chrnx 43a4316a29 fix(fetch): gate x-forwarded-for on trustProxy in app.fetch
The Web-Standards fetch adapter read x-forwarded-for unconditionally to
seed ctx.ip, unlike Node's deriveIp which only honours it when
trustProxy is enabled. A client could spoof ctx.ip on any handler
relying on it. Mirror deriveIp's first-hop semantics and only trust
the header when trustProxy is set; otherwise ctx.ip is ''.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 14:45:27 -05:00
chrnx 1fee7de543 docs: app.fetch runtimes guide (Node/Deno/Bun/edge)
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 14:37:12 -05:00
chrnx b75f127b2c fix(http): merge security headers into app.fetch CORS preflight responses
Add a Node-vs-app.fetch parity suite that drives GET/POST/404/CORS-preflight/SSE
through both the real Node server and app.fetch and asserts identical status,
headers, and body. It caught a real divergence: buildFetch's preflight branch
returned only the CORS-specific headers, skipping the security headers
(x-content-type-options, x-frame-options, referrer-policy, x-dns-prefetch-control)
that the Node adapter's writeHead patch applies to every response including the
204 preflight. Fix buildFetch to merge `injected` into the preflight response the
same way, so both paths agree.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 14:33:31 -05:00
chrnx 08cb8554e6 fix(fetch): security headers on early failures, live mesh boot gate
app.fetch's 413/400/501 body-acquisition failures were returned without
the injected security/CORS headers Node's writeHead patch always
applies, breaking byte-identical parity with the listen() path. Extract
computeInjected() (shared by handle() and buildFetch()) and merge it
into every error response, not just handle()'s outcomes.

Also, buildAppFetch captured `booted` by value at createApp() time, so
mesh apps (whose finalize() is deferred into listen()) had app.fetch
permanently throw even after a successful listen(). Read booted live
via a getter, mirroring explain()/graph()/inspect(), and lazily
build/cache the fetch handler on first call after boot.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 14:26:45 -05:00
chrnx 93a4246de5 feat(app): app.fetch — Web-Standards handler over the neutral core
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 14:15:26 -05:00
chrnx fc75cc05e5 feat(http): asReadableStream — AsyncIterable to web ReadableStream
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 14:04:03 -05:00
chrnx 16823408c7 refactor(http): extract runtime-neutral handle() core
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 13:58:35 -05:00
chrnx 118eb5516d refactor(http): extract mergeInjectedHeaders pure helper
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 13:51:55 -05:00
chrnx 9d97443847 feat(brand): Green Tea. identity — logo, wordmark, branded graph & docs
CI / build (push) Has been cancelled
Ship the visual brand across the framework:
- assets/ (logo.svg, logo-mono.svg, logo.png), included in the npm files list
- README header: leaf mark + Green Tea. + tagline; package description aligned
- /__graph__ viewer header now shows the logo + Green Tea. wordmark (Zen Maru)
- website/ (Starlight): matcha accent, Zen Maru headings, logo, favicon, hero

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 13:33:04 -05:00
chrnx aaafe76d8f feat(graph): color-code endpoint method and transport in the viewer
CI / build (push) Has been cancelled
Follow-up to the interactive viewer. Route nodes were arrow 'tag' shapes
that read as disruptive and edges were thick. Calm them down: routes are
now rounded rectangles with thinner edges.

Encode two axes visually on each endpoint — fill colour = HTTP method
(GET/POST/PUT/PATCH/DELETE), border style = transport (solid HTTP, dashed
SSE, double WS) — with a legend that explains node types, edge kinds,
transports and methods.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 11:06:47 -05:00
chrnx 27a984f070 feat(graph): interactive Cytoscape viewer for /__graph__
CI / build (push) Has been cancelled
Mermaid's static diagram overlaps badly as the graph grows. Replace the
/__graph__ HTML with an interactive Cytoscape.js + dagre viewer (both loaded
from a CDN, so no runtime dependency is added — the one-dep pitch holds).

Clicking a route lights up its real transitive slice and dims the rest;
clicking a provider/step shows its blast radius. Edges are colour-coded by
kind (needs vs feeds-endpoint), provider/step/endpoint nodes are visually
distinct, and nodes are draggable. toMermaid()/toDOT() and the text/plain
path are unchanged.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-09 10:44:03 -05:00
chrnx 2db5de6858 feat: per-route body limits, custom error rendering, OpenAPI generation
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>
2026-07-08 08:29:17 -05:00
chrnx 7c20d74fe4 chore(release): publish metadata + normalize version to 26.7.0-beta.0
CI / build (push) Has been cancelled
Add the npm metadata needed to publish the scoped package —
`publishConfig.access: "public"` (without it a scoped package publishes
private), `engines`, `keywords`, `author` — and a CHANGELOG entry for the
first beta.

Normalize the version to 26.7.0-beta.0: npm treats versions as semver and
strips the month's leading zero, so 26.07.0 publishes as 26.7.0 regardless.
Align package.json, the VERSION export, the README, and the smoke test.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-07 16:04:20 -05:00
chrnx 40d3390ddb Merge pull request 'Feature/beta hardening' (#1) from feature/beta-hardening into develop
CI / build (push) Has been cancelled
Reviewed-on: #1
2026-07-07 20:21:27 +00:00
chrnx 654c0563fc 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>
2026-07-07 12:02:17 -05:00
chrnx d6c5cee0ee feat: beta-hardening — routing, degradation, mesh gate, uploads, @header
Restructure first: split the two oversized files by cohesion (http.ts 449
→ http/{router,request,stream,ws,server,types}; app.ts 556 → app/{types,
introspect,index}), rename cryptic locals, JSDoc the public API, and
extract helpers so no function exceeds the complexity gate (createApp
187 → <15, listen 113 → 6). Public import paths are unchanged (barrels).

On that structure, five features that close the biggest gaps vs
Express/Fastify/Nest for a comparable beta:

- routing: `:name*` catch-all, specificity precedence (static ▸ param ▸
  catch-all, not registration order), and 405 + Allow when a path exists
  under a different method (was 404)
- visible degradation: optional providers that fail boot are summarized on
  listen() and queryable via app.degraded(), instead of a silent warn
- mesh is alpha — gated behind `experimental: true`; createApp throws if
  `mesh` is configured without it
- multipart moves to the optional `busboy` peer dependency (clear 501 when
  absent), keeping the core at one runtime dependency
- `@header('name')` as a singular alias of `@headers`

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-07 12:00:15 -05:00
chrnx 9d79972f62 chore(release): dual ESM/CJS build via tsup; fix packaging; 26.07.0-beta.0
Packaging was broken for consumers: `main` resolved to a nonexistent
dist/index.js (tsc emitted dist/src/index.js), and the tarball shipped
tests, benches and sources. Build with tsup to emit CJS + ESM (+ types)
behind an `exports` map so `require` and `import` both resolve; a
createRequire banner keeps the lazy require('ws')/require('busboy') working
under ESM. Add the `files` allowlist and a `prepublishOnly` gate.

Bump to the first CalVer beta, published under the npm `beta` dist-tag.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-07 11:59:57 -05:00
chrnx 3ca4c8680e chore(qa): add ESLint, Prettier, and a cognitive-complexity gate
The project shipped no linting or formatting; add both ahead of the first
npm publish. ESLint (flat config, typescript-eslint) + Prettier enforce a
consistent style, and a cognitive-complexity gate (ccts, threshold 25)
keeps any function from regressing into the unreadable.

Both run in CI and in a pre-commit hook (.githooks, enabled via
core.hooksPath + the `prepare` script). Cyclomatic complexity stays
advisory-only — its ??-chain false positives make it a poor gate.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-07 11:59:42 -05:00
chrnx bb960ee669 Merge docs/readme-realtime: real-time primitive section
CI / build (push) Has been cancelled
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-07 00:28:51 -05:00
chrnx 0df82479ee docs: push the real-time story — one AsyncIterable primitive, explained
Add a dedicated section explaining that real-time is native (not a bolt-on
Gateway/adapter/plugin like other frameworks), and that the primitive is always
an AsyncIterable — you declare the mode (@Sse/@Ws/@Stream) and what changes is
direction and framing. Explains the difference between each iterable exposed
(outbound return vs @inbound, channel/rooms fan-out).

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-07 00:28:51 -05:00
chrnx 5bab8da84b Merge docs/readme-refresh: sellable README + CHANGELOG
CI / build (push) Has been cancelled
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-07 00:12:59 -05:00