-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
Description
Description
Currently, several API route handlers contain business logic that should be extracted to reusable utility functions in the @/lib
directory. This will improve code maintainability and reusability.
Files that need refactoring
1. src/app/api/papers/route.ts
Extract to /lib
:
escapeRegExp
utility function (duplicated across files)- Paper aggregation logic for extracting unique values: years, slots, exams, campuses, semesters
2. src/app/api/related-subject/route.ts
Extract to /lib
:
escapeRegExp
utility function (duplicate)- Subject matching/filtering logic
3. src/app/api/subscribe/route.ts
Extract to /lib
:
getAuth
Google Sheets authentication functionappendEmailToSheet
Google Sheets API interaction
4. src/app/api/upcoming-papers/route.ts
Extract to /lib
:
- Slot calculation logic (next slot determination)
- Corresponding slots array generation logic
Benefits
- Improved code reusability
- Better separation of concerns
- Reduced code duplication
- More maintainable codebase