Repository navigation
docs(skills): add /api-client — typed client recipe for response routes - #540
Merged
Merged
Conversation
commit: |
ivogt
force-pushed
the
docs/typed-client-skill
branch
from
June 7, 2026 16:13
25ffd10 to
fe7bdee
Compare
…es [skip ci]
A copy-paste recipe (not a new framework export) for consuming your own
path.json() APIs from first-party TypeScript: route params typed + required
from the pattern (optional-only params still passable), response payloads
typed via RouteResponse (no codegen, no `.data`), typed ProblemDetails errors.
Client-safe by construction: only type-only imports from @rangojs/router plus
an in-helper path builder — no createReverse (a server/RSC-only export that
throws in the browser). Accepts both string and { path } route-map entries.
`body` is `unknown` (serialized JSON); typed request input is out of scope.
Compile-verified against api-shop + search routes and the full param-arity
matrix (no-param, required, optional-only, mixed). Indexed in /rango;
cross-linked from /response-routes. Docs-only; no runtime change.
ivogt
force-pushed
the
docs/typed-client-skill
branch
from
June 7, 2026 17:22
fe7bdee to
76c0ae4
Compare
ivogt
added a commit
that referenced
this pull request
Jun 9, 2026
Bring in main (#540-#551: dev/prod matching stability + lazy-include fixes, perf benchmarks, docs reorg/archive, release 0.0.0-experimental.116). Resolve the two internal docs-map conflicts (feature-file-map.md, feature-map.md) by keeping main's cell updates AND the branch's testing rows (the "Consumer testing primitives" row and the six ./testing* export-surface rows). Gate: typecheck 12/12, test:unit:all EXIT=0 (router 3537 + 6 todo, cloudflare-basic 39, RSC 27), lint 0/0, format.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a new skill,
/api-client, that teaches consumers how to consume their ownpath.json()response-route APIs from first-party TypeScript with a typed client — and ships a ~50-line copy-paste helper that does it.Follow-up to #539 (bare-
T+ RFC 9457 problem+json). It's a recipe, not a new framework export: the helper composes existing public exports (RouteResponse,ExtractParams,createReverse). Docs-only — no runtime or public-API change.Why
Today, consuming your own API with types means hand-rolling a client per app (the test-app's
api-shop-client.tsis ~105 lines of it), and the default consumer who skips that getsfetch(url).then(r => r.json())→any. The recipe collapses that to:RouteResponse), no codegen.ApiErrorcarrying theProblemDetailsbody.Scope call-out (deliberate)
The typed client is a first-party TypeScript convenience — it needs your route types. External/third-party consumers use the plain wire directly (bare JSON +
application/problem+json), which needs no client. Language-agnostic OpenAPI generation is intentionally deferred as the separate third-party lever. The skill states this explicitly so nobody mistakes the recipe for a third-party SDK.Verification
The helper was compile-verified against the
e2e/test-appapi-shop routes (temporary type-test, since removed): required-param enforcement, no-arg paramless routes, typed.post({ body }), and@ts-expect-erroron unknown routes / wrong param names.typecheck,lint,formatall green.Surface
skills/api-client/SKILL.md(new)skills/rango/SKILL.md— indexed in the skill tableskills/response-routes/SKILL.md— cross-linked ("Consuming response routes")