Skip to content

Commit 6a88b9d

Browse files
committed
docs: align client route-tree guidance
Update README, context docs, and public TSDoc after removing low-level request factories and renaming the client metadata property. The docs now emphasize generated route action calls, the required routes option, and clientConfig as the non-colliding metadata property.
1 parent cff424e commit 6a88b9d

4 files changed

Lines changed: 17 additions & 14 deletions

File tree

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
Rouzer lets you declare an HTTP route tree once and share its TypeScript types
44
and Zod validation between a Hattip-compatible server and a typed fetch client.
5+
The client is always created from that route tree.
56

67
## What it does
78

@@ -45,7 +46,7 @@ Consider something else if:
4546
- Zod v4 or newer
4647
- a Hattip adapter when using `createRouter(...)`
4748
- a Fetch API implementation when using `createClient(...)`
48-
- an absolute `baseURL` for generated client URLs
49+
- an absolute `baseURL` and shared `routes` tree for generated client URLs
4950

5051
## Installation
5152

@@ -101,9 +102,9 @@ const { message } = await client.hello({
101102
})
102103
```
103104

104-
`handler` can be mounted with any Hattip adapter. Client action calls validate
105-
route arguments before `fetch`; server handlers validate matched path, query,
106-
headers, and JSON bodies before your handler runs.
105+
`handler` can be mounted with any Hattip adapter. Generated client action calls
106+
validate route arguments before `fetch`; server handlers validate matched path,
107+
query, headers, and JSON bodies before your handler runs.
107108

108109
### Typed status responses
109110

docs/context.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ const client = createClient({
233233

234234
Default headers can be supplied with `headers`, per-request headers are merged on
235235
top, and a custom `fetch` implementation can be supplied for tests or non-browser
236-
runtimes.
236+
runtimes. The returned client exposes the original options as `clientConfig`, so
237+
route actions named `config` remain available as `client.config(...)`.
237238

238239
## Lifecycle
239240

@@ -459,7 +460,7 @@ await client.profiles.update({
459460
- Export route trees from a small shared module and import that module on both
460461
server and client.
461462
- Use `rouzer/http` actions for routes that are registered with
462-
`createRouter().use(...)` or `createClient({ routes })`.
463+
`createRouter().use(...)` or the required `createClient({ routes })` option.
463464
- Add Zod schemas when you need runtime guarantees; rely on inferred path params
464465
only when string params are sufficient.
465466
- Use `response: $type<T>()` for JSON endpoints that should have typed client
@@ -489,8 +490,9 @@ await client.profiles.update({
489490
- Resource and action keys are API names only; paths come from the pattern
490491
strings passed to `http.resource(...)` and action helpers.
491492
- Extra `RequestInit` fields in route args, such as `signal` or `credentials`,
492-
are forwarded by `createClient`; `method`, `body`, and `headers` are reserved
493-
for Rouzer's action metadata and validated call arguments.
493+
are forwarded by `createClient`; `method` and `body` are reserved for Rouzer's
494+
action metadata and validated call arguments. Use route args or client defaults
495+
for request headers.
494496
- The HTTP action API has no `ALL` fallback route. Declare explicit actions for
495497
supported methods.
496498
- Rouzer does not automatically set `Access-Control-Allow-Credentials`; set it in

src/client/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ export function createClient<
5858
/** Response codec plugins used by generated action functions. */
5959
plugins?: readonly ClientResponsePlugin[]
6060
/**
61-
* Custom handler for non-2xx responses from `.json()` and generated response
62-
* helpers.
61+
* Custom handler for non-2xx responses from generated client action
62+
* functions.
6363
*
64-
* @remarks When provided, the return value is returned from the response
65-
* helper as-is; Rouzer does not automatically parse a `Response` returned by
66-
* this hook.
64+
* @remarks When provided, the return value is returned from the client action
65+
* as-is; Rouzer does not automatically parse a `Response` returned by this
66+
* hook.
6767
*/
6868
onJsonError?: (response: Response) => Promisable<unknown>
6969
/** Custom `fetch` implementation to use for requests. */

src/types/args.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type MutationArgs<T> = T extends MutationRouteSchema
3535
: unknown
3636

3737
/**
38-
* Arguments accepted by a client action function or low-level request factory.
38+
* Arguments accepted by a generated client action function.
3939
*
4040
* @remarks The type is derived from an action schema and route pattern. `path`,
4141
* `query`, `body`, and `headers` are validated by the client before `fetch` when

0 commit comments

Comments
 (0)