Documentation
@tahanabavi/typefetch
A strongly typed TypeScript HTTP client powered by Zod contracts, middleware, retries, mock data, response wrappers, field encryption, contract testing, CLI workflows, and report generation.
Latest v1.6.4
Overview
The package turns Zod endpoint contracts into a runtime-safe and type-safe API client.
TypeFetch is built around one idea: define every API endpoint once as a Zod contract, then let the client generate typed module methods, validate request input, validate successful responses, run middleware, and power contract-driven tests from the same source of truth.
- Typed modules are generated from the contract object after client.init().
- Requests are validated before fetch is called.
- Responses are validated before data reaches application code.
- Structured input supports path, query, body, and headers.
- The same endpoint metadata powers mock mode, encryption, CLI tests, and reports.
ts
01const user = await api.user.getUser({02 path: { id: "123" },03});0405console.log(user.name);1 / 36