-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
The fetchDirectoryData function is extremely large and handles multiple types of queries (token holders, Farcaster channels, CSVs) and complex logic within a single API handler.
This violates the "Single Responsibility Principle".
Impact
- Scalability: The API route becomes a bottleneck.
- Readability: It is difficult to understand the flow of the request.
- Error Handling: With so much logic in one place, error handling becomes generic and difficult to manage granularly.
- Timeouts: Vercel/Next.js serverless functions have execution time limits. Performing heavy processing (like large CSV parsing or multiple external API calls) in one handler risks timeouts.
Recommendation
- Refactor the logic into separate service classes or functions (e.g.,
TokenService,FarcasterService). - Create separate API endpoints for distinct operations if they are independent.
- For heavy tasks, consider using background jobs or edge functions.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
No status