The Result Type pattern is a common FP pattern for expressing success/failure explicitly. We need a framework helper that works with the normalizer component to be used in the interface layer to consistently convert Result values into HTTP responses, including both serialized success resources and mapped errors.
Motivation:
Today, controllers often duplicate response-shaping logic. A dedicated helper would:
- Standardize success/error HTTP mapping
- Keep controllers thin and consistent
- Reuse the existing normalizer for resource serialization
- Improve type safety and maintainability across endpoints
Proposal:
Add createResultToHttpMapper to the serializer/http utilities so applications can:
- Map success results to
{ status, body: { data: ... } }
- Serialize success payloads through normalizer options
- Map typed errors to configured HTTP statuses
- Define fallback behavior for unmapped errors
Note: Here is an implementation from Kairos.
The Result Type pattern is a common FP pattern for expressing success/failure explicitly. We need a framework helper that works with the
normalizercomponent to be used in the interface layer to consistently convert Result values into HTTP responses, including both serialized success resources and mapped errors.Motivation:
Today, controllers often duplicate response-shaping logic. A dedicated helper would:
Proposal:
Add
createResultToHttpMapperto the serializer/http utilities so applications can:{ status, body: { data: ... } }Note: Here is an implementation from Kairos.