Context
Campaign and donation code now have focused service and validation tests, but the distribution API still has controller/service behavior that returns raw 500 responses for several expected cases and has no matching regression coverage in src/__tests__. The distribution endpoints should have predictable validation, not-found, and database-not-ready responses before more clients depend on them.
Scope
Out of Scope
- Changing the distribution entity schema
- Adding authentication requirements unless a separate product decision exists
- Implementing indexer distribution persistence
Acceptance Criteria
Dependencies
Suggested Files or Packages
src/components/v1/distribution/
src/__tests__/
src/utils/apiResponse.ts
src/utils/errorHandler.ts
Context
Campaign and donation code now have focused service and validation tests, but the distribution API still has controller/service behavior that returns raw 500 responses for several expected cases and has no matching regression coverage in
src/__tests__. The distribution endpoints should have predictable validation, not-found, and database-not-ready responses before more clients depend on them.Scope
POST /v1/distributions,PATCH /v1/distributions/:id, andGET /v1/distributionspolicyMiddlewareconsole.errorhandling with project logger or shared error handling conventionsOut of Scope
Acceptance Criteria
bun run testwith coverage thresholds intactbun run type-checkpassesbun run testpassesbun run lintpassesDependencies
Suggested Files or Packages
src/components/v1/distribution/src/__tests__/src/utils/apiResponse.tssrc/utils/errorHandler.ts