Description
GET /api/developers/revenue (src/routes/developerRoutes.ts:134-137, validated by the revenueQuerySchema Zod object at src/routes/developerRoutes.ts:38) returns a paginated JSON summary of settlements and aggregated earnings via res.json(...). Developers reconciling payouts for accounting have no machine-friendly bulk export and must page through JSON. This issue adds a downloadable export (CSV and full JSON) of a developer's settlement and revenue history.
Requirements and context
- Add
GET /api/developers/revenue/export (authenticated via the existing requireAuth middleware used in src/routes/developerRoutes.ts).
- Support
format=csv and format=json query params; reuse the same revenue aggregation/data source already feeding GET /api/developers/revenue so totals stay consistent (the route already computes "only positive amounts count" — see src/routes/developerRoutes.ts:176).
- For CSV, set
Content-Type: text/csv and a Content-Disposition: attachment filename; emit a stable header row (e.g. settlement id, amount_usdc, status, tx_hash, created_at, completed_at) drawn from the Settlement shape in src/types/developer.ts.
- Validate
format with a Zod schema via the shared validate(...) middleware (src/middleware/validate.ts), mirroring how revenueQuerySchema is applied at src/routes/developerRoutes.ts:137.
- Non-functional: enforce a bounded maximum row count or date window to avoid unbounded responses; respect the per-user REST rate limiting already applied to developer traffic.
Acceptance criteria
Suggested execution
1. Fork the repo and create a branch
git checkout -b feature/developer-revenue-export
2. Implement changes — add the export route and a small CSV serializer in src/routes/developerRoutes.ts (or a src/lib/ helper); add the format Zod schema.
3. Write/extend tests — extend src/__tests__/developerRevenue.test.ts and/or add a new *.test.ts (Jest + supertest).
4. Test and commit
npm run lint
npm run typecheck
npm test -- developerRevenue --runInBand
Example commit message
feat(developers): add CSV/JSON revenue export endpoint
Guidelines
Maintain the repo's 90%+ coverage target (README.md). Add JSDoc to the new route describing query params and response formats, and document the endpoint in README.md next to the existing developer endpoints. Timeframe: 96 hours.
Description
GET /api/developers/revenue(src/routes/developerRoutes.ts:134-137, validated by therevenueQuerySchemaZod object atsrc/routes/developerRoutes.ts:38) returns a paginated JSON summary of settlements and aggregated earnings viares.json(...). Developers reconciling payouts for accounting have no machine-friendly bulk export and must page through JSON. This issue adds a downloadable export (CSV and full JSON) of a developer's settlement and revenue history.Requirements and context
GET /api/developers/revenue/export(authenticated via the existingrequireAuthmiddleware used insrc/routes/developerRoutes.ts).format=csvandformat=jsonquery params; reuse the same revenue aggregation/data source already feedingGET /api/developers/revenueso totals stay consistent (the route already computes "only positive amounts count" — seesrc/routes/developerRoutes.ts:176).Content-Type: text/csvand aContent-Disposition: attachmentfilename; emit a stable header row (e.g. settlement id, amount_usdc, status, tx_hash, created_at, completed_at) drawn from theSettlementshape insrc/types/developer.ts.formatwith a Zod schema via the sharedvalidate(...)middleware (src/middleware/validate.ts), mirroring howrevenueQuerySchemais applied atsrc/routes/developerRoutes.ts:137.Acceptance criteria
GET /api/developers/revenue/export?format=csvreturnstext/csvwith an attachment disposition and a deterministic header row.GET /api/developers/revenue/export?format=jsonreturns the full export as JSON.GET /api/developers/revenue.formatvalues return the standard400validation envelope (code,message,details).401.Suggested execution
1. Fork the repo and create a branch
2. Implement changes — add the export route and a small CSV serializer in
src/routes/developerRoutes.ts(or asrc/lib/helper); add theformatZod schema.3. Write/extend tests — extend
src/__tests__/developerRevenue.test.tsand/or add a new*.test.ts(Jest +supertest).4. Test and commit
npm run lint npm run typecheck npm test -- developerRevenue --runInBandExample commit message
Guidelines
Maintain the repo's 90%+ coverage target (
README.md). Add JSDoc to the new route describing query params and response formats, and document the endpoint inREADME.mdnext to the existing developer endpoints. Timeframe: 96 hours.