Skip to main content
zerotal

Documentation


Documentation / @zerotal/client / index / ApiRouteMap

Type Alias: ApiRouteMap

ApiRouteMap = Partial<Record<`${HttpMethod} ${string}`, RouteShape>>

Defined in: client/src/types.ts:72

The route type map you write (or generate) for your API.

Keys are 'METHOD /path' strings — e.g. 'GET /api/users/{id}'.

Example

export interface Routes {
  'GET /api/users': {
    query:    { page?: number; perPage?: number };
    response: { data: UserResource[]; total: number };
  };
  'GET /api/users/{id}': {
    params:   { id: string | number };
    response: UserResource;
  };
  'POST /api/users': {
    body:     { name: string; email: string; password: string };
    response: UserResource;
  };
  'DELETE /api/users/{id}': {
    params:   { id: string | number };
    response: void;
  };
}