Summary
The apps/backend/src/routes/public.ts route handlers currently contain repeated inline response transformation logic for public profile, card, and link-related payloads.
Several route handlers manually construct response objects with similar transformation patterns, including:
- public profile formatting
- card response shaping
- public link transformation and serialization
This duplication increases maintenance overhead and makes future schema or response updates more difficult to manage consistently across the backend.
Proposed Refactor
Introduce reusable transformer/helper utilities for constructing public response payloads instead of repeating inline object mapping logic across route handlers.
Potential extraction targets include:
- public profile response transformation
- public card response formatting
- link serialization/transformation logic
The goal is to centralize response shaping behavior while preserving the existing API contract and route behavior.
Expected Benefits
- Reduce duplicated backend transformation logic
- Improve maintainability and readability
- Standardize response formatting across public routes
- Simplify future schema and response updates
- Improve long-term scalability of route handlers
Scope
Primary target:
apps/backend/src/routes/public.ts
Additional helper utilities may be introduced if necessary, while keeping the refactor minimal, isolated, and fully backward compatible.
Acceptance Criteria
- Repeated inline response mapping logic is reduced
- Existing API responses remain unchanged
- Refactor remains fully backward compatible
- Route readability and maintainability are improved
- No unrelated backend functionality is modified
Notes
This issue focuses strictly on backend refactoring and maintainability improvements without introducing new features or changing API behavior.
Summary
The
apps/backend/src/routes/public.tsroute handlers currently contain repeated inline response transformation logic for public profile, card, and link-related payloads.Several route handlers manually construct response objects with similar transformation patterns, including:
This duplication increases maintenance overhead and makes future schema or response updates more difficult to manage consistently across the backend.
Proposed Refactor
Introduce reusable transformer/helper utilities for constructing public response payloads instead of repeating inline object mapping logic across route handlers.
Potential extraction targets include:
The goal is to centralize response shaping behavior while preserving the existing API contract and route behavior.
Expected Benefits
Scope
Primary target:
Additional helper utilities may be introduced if necessary, while keeping the refactor minimal, isolated, and fully backward compatible.
Acceptance Criteria
Notes
This issue focuses strictly on backend refactoring and maintainability improvements without introducing new features or changing API behavior.