Closed changchunlei closed 1 month ago
It seems you forgot to remove 'questionOfTodayQuery' from the app.ts
file in the import section. This may cause issues when running build and start commands.
Your Proposal is absolutely good 😀 and I also thought about it a while ago but never implemented it 😅.
Why did your routes look like this?
/userProfile/:username
/userProfileCalendar?username=yourname&year=2024
/languageStats?username=yourname
/userProfileUserQuestionProgressV2/:userSlug
/skillStats/:username
/userContestRankingInfo/:username
Why not this?
:username/userProfile
:username/calendar?year=2024
:username/languageStats
:username/userProfileUserQuestionProgressV2
:username/skillStats
:username/userContestRankingInfo
Agree. We should spend some time to make the API queries in a consistent format. That's a to do item.
Hi Alfa,
This pull request includes refactoring two endpoints /trendingDiscuss and /languageStats to align with the original code structure.
Refactoring Details:
Aligned the structure of two endpoints with the original code format. Removed a few __typename from all graph queries Removed 7-8 lines of my previous code and added 100+ lines of code across multiple files to maintain consistency with the existing structure. Removed one duplicated daily question API
Suggestions and Rationale:
While I can see the rationale behind the existing code structure, including the separation of queries and controllers and the formatting approach, I would like to propose an alternative based on my recent frontend dev exerpeince. The primary purpose of this API is to simplify GraphQL queries into REST API endpoints. As such, I believe the GraphQL queries should be the main source for formatting data rather than relying on a middleware formatter. Using a middleware formatter introduces additional complexity. Without sepeific frontend requirement to tailor backend for the frontend, I don't think it makes sense to format the data returned from LeetCode in this manner.
Proposal: Moving forward, I suggest that we consider using GraphQL queries directly for data formatting. This approach could streamline the API development process and reduce the amount of code needed for formatting. It would also make it easier for frontend developers to work with the API.
I look forward to discussing this further and hearing your thoughts.