@forinda/kickjs-client
v0.3.0
Published
Typed fetch client for KickJS APIs — end-to-end response types from the kick typegen KickRoutes augmentation
Downloads
757
Maintainers
Readme
@forinda/kickjs-client
Typed fetch client for KickJS APIs — end-to-end response
types powered by kick typegen's KickRoutes.Api map.
pnpm add @forinda/kickjs-clientimport { createClient } from '@forinda/kickjs-client'
const api = createClient<KickApi>({ baseUrl: 'https://api.example.com/api/v1' })
const task = await api.get('/tasks/:id', { params: { id: '42' } })
// ^ the handler's actual response type — inferred, not declared
const created = await api.post('/tasks', { body: { title: 'Ship it' } })- Paths + params + body typed from the generated
KickRoutes.Api; response types flow from your controller handlers (return-value style) viaInferHandlerResponse. - Runtime-neutral: fetch/URL/Headers only — browsers, node ≥ 20, Bun, Deno, edge workers. Zero dependencies.
- Typed errors: non-2xx throws
KickClientErrorcarrying the parsed body (RFC 9457 problem details when the server usedctx.problem). - Injectable fetch: pass
{ fetch: app.fetch }from@forinda/kickjs/webfor network-free integration tests.
