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
This component requires additional Servercn components.
👉 You do not need to install any Servercn components manually. Running this component installer will automatically install all required components. Manual installation is optional and only recommended if you prefer fine-grained components control
1. Install Servercn components(Optional)
2. Install this component
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