HTTP Client Generation

Generate TypeScript-safe HTTP clients from schemas

Info:

Coming Soon - This feature is planned for a future release and is not yet available.

Goal

Frontend developers get auto-completed, type-safe API calls.


Source of Truth

  • presentation/http/{resource}/{endpoint}/request.dto.ts
  • presentation/http/{resource}/{endpoint}/response.dto.ts

Generated Output

packages/shared/clients/http/user.client.ts

class UserClient {
  constructor(
    private readonly baseUrl: string,
    private readonly auth: AuthConfig,
  ) {}

  async getUser(userId: string): Promise<GetUserResponse> {
    const response = await fetch(`${this.baseUrl}/users/${userId}`, {
      headers: this.auth.headers(),
    });
    return getUserResponseSchema.parse(await response.json());
  }

  async createUser(data: CreateUserRequest['body']): Promise<CreateUserResponse> {
    // ...
  }
}

Usage

const userClient = new UserClient('https://api.example.com', authConfig);
const user = await userClient.getUser('123');  // Fully typed!