
@tahanabavi/typefetch
A strongly typed TypeScript HTTP client powered by Zod contracts — with middleware, retries, mock data, response wrappers, typed error responses, response types, upload/download progress, contract-linked permissions, runtime instrumentation, field encryption, contract testing, and CLI report generation.
Latest v1.10.0
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.
- Response types, upload/download progress, typed error responses, permissions, and instrumentation all extend the same contract.
- 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 / 46