@signapps/api-client
A generated, type-safe RTK Query client for the API — Redux hooks for every endpoint, with automatic cache invalidation and runtime Zod response validation.
- Workspace:
packages/api-client - Depends on:
@signapps/types(for response schemas) - Build:
tsc -p tsconfig.json→dist/
How it's generated
A two-step codegen runs from the API's OpenAPI spec
(apps/api/docs/openapi.json):
scripts/generate-response-schemas.mjsscans the spec and maps each endpoint'soperationIdto the matching Zod schema from@signapps/types/dto/*, writingendpointResponseSchemas.ts.rtk-query-codegen-openapigeneratesgeneratedApi.ts(queries, mutations, lazy queries, and React hooks).
enhancedApi.ts then wraps the generated API to (a) run transformResponse Zod
validation on every endpoint that has a matching schema and (b) add custom
providesTags/invalidatesTags for cache management. authBridge.ts wires
token lifecycle.
Run codegen with:
pnpm generate:api-client
Exports
From index.ts:
api— the enhanced RTK Query instancesetApiTokenGetter,setOnUnauthorized— auth hooks- everything from
generatedApi— the typed React hooks (e.g.useListCustomersQuery,useCreateCustomerMutation, …)
Generated file
src/generatedApi.ts and src/endpointResponseSchemas.ts are generated and
gitignored — never edit them by hand. Change the API's OpenAPI source and
re-run codegen instead.
Consumed by
Web admin (and other React apps).