diff --git a/README.md b/README.md index 99bcd35..89c5eeb 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ During development, it's recommended to utilize the API locally. To do so, follo | _Discussion Topic_ | `/discussTopic/:topicId` | get discussion topic | | _Discussion Comment_ | `/discussComments/:topicId` | get discussion comments | | _Raw Daily Problem_ | `/dailyQuestion` | get raw daily question | +| _Raw Selected Problem_ | `/selectQuestion?titleSlug=selected-question` | get raw selected question | ### ❓Questions Details diff --git a/src/app.ts b/src/app.ts index 981f5aa..ac77a20 100644 --- a/src/app.ts +++ b/src/app.ts @@ -243,6 +243,9 @@ app.get('/daily', leetcode.dailyProblem); //get the selected question app.get('/select', leetcode.selectProblem); +// get the selection question raw +app.get('/selectQuestion', leetcode.selectProblemRaw); + //get list of problems app.get('/problems', leetcode.problems); diff --git a/src/leetCode.ts b/src/leetCode.ts index 70a9840..2266170 100644 --- a/src/leetCode.ts +++ b/src/leetCode.ts @@ -113,11 +113,29 @@ export const selectProblem = (req: Request, res: Response) => { } }; +export const selectProblemRaw = (req: Request, res: Response) => { + const title = req.query.titleSlug as string; + if (title !== undefined) { + controllers.fetchSingleProblem( + res, + e => e, + gqlQueries.selectProblemQuery, + title + ); + } else { + res.status(400).json({ + error: 'Missing or invalid query parameter: titleSlug', + solution: 'put query after select', + example: 'localhost:3000/select?titleSlug=two-sum', + }); + } +} + export const problems = ( req: Request<{}, {}, {}, { limit: number; skip: number; tags: string; difficulty: string }>, res: Response ) => { - const difficulty=req.query.difficulty; + const difficulty = req.query.difficulty; const limit = req.query.limit; const skip = req.query.skip; const tags = req.query.tags; @@ -148,7 +166,7 @@ export const trendingCategoryTopics = (_req: Request, res: Response) => { example: 'localhost:3000/trendingDiscuss?first=20', }); } - + }; export const languageStats = (_req: Request, res: Response) => { @@ -167,5 +185,5 @@ export const languageStats = (_req: Request, res: Response) => { example: 'localhost:3000/languageStats?username=uwi', }); } - + }; \ No newline at end of file