API Response Formatter
The API Response Formatter component provides a consistent, predictable, and type-safe response structure for Express-based APIs.
It enforces a unified response contract across your entire backend, improving:
- Client-side reliability
- API readability
- Error handling consistency
- Developer experience
This component is designed to work seamlessly with:
- Async Handler
- ApiError
- Centralized error middleware
- Frontend API clients
Installation Guide
npx servercn-cli add response-formatterThe Problem It Solves
In many Express applications, responses quickly become inconsistent:
Basic Implementation
MVC: src/utils/api-response.ts
Feature: src/shared/utils/api-response.ts