What problem does it solve?
Provides a consistent pattern for processing HTTP requests and producing standardized API responses, reducing duplicated error handling and inconsistent response shapes across a codebase.
Core Features & Use Cases
- Unified Error Handling: Enforce wrapping handler logic with an errorHandler wrapper that catches JSON parsing issues, service errors, and Prisma-specific errors and maps them to proper HTTP statuses.
- Request Parsing & Validation: Demonstrates reliable parsing of JSON bodies, route parameters, and query parameters, with examples for authentication checks and input validation for common CRUD operations.
- Response Formatting & Mapping: Supplies success and failure helper patterns to return consistent payloads and shows mapper usage to transform service models into API responses; ideal for REST endpoints like user, baby, and activity resources.
Quick Start
Wrap your handler logic in the errorHandler wrapper, parse the request body or params as shown, perform service operations, and return results using the success or fail helpers.