Skip to content

Commit 5322a65

Browse files
authored
Merge pull request #60 from Ar0manKhan/main
feat: new API to get raw version of selected question.
2 parents d362520 + a243cb5 commit 5322a65

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ During development, it's recommended to utilize the API locally. To do so, follo
7474
| _Discussion Topic_ | `/discussTopic/:topicId` | get discussion topic |
7575
| _Discussion Comment_ | `/discussComments/:topicId` | get discussion comments |
7676
| _Raw Daily Problem_ | `/dailyQuestion` | get raw daily question |
77+
| _Raw Selected Problem_ | `/selectQuestion?titleSlug=selected-question` | get raw selected question |
7778

7879
### ❓Questions Details
7980

src/app.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ app.get('/daily', leetcode.dailyProblem);
243243
//get the selected question
244244
app.get('/select', leetcode.selectProblem);
245245

246+
// get the selection question raw
247+
app.get('/selectQuestion', leetcode.selectProblemRaw);
248+
246249
//get list of problems
247250
app.get('/problems', leetcode.problems);
248251

src/leetCode.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,29 @@ export const selectProblem = (req: Request, res: Response) => {
113113
}
114114
};
115115

116+
export const selectProblemRaw = (req: Request, res: Response) => {
117+
const title = req.query.titleSlug as string;
118+
if (title !== undefined) {
119+
controllers.fetchSingleProblem(
120+
res,
121+
e => e,
122+
gqlQueries.selectProblemQuery,
123+
title
124+
);
125+
} else {
126+
res.status(400).json({
127+
error: 'Missing or invalid query parameter: titleSlug',
128+
solution: 'put query after select',
129+
example: 'localhost:3000/select?titleSlug=two-sum',
130+
});
131+
}
132+
}
133+
116134
export const problems = (
117135
req: Request<{}, {}, {}, { limit: number; skip: number; tags: string; difficulty: string }>,
118136
res: Response
119137
) => {
120-
const difficulty=req.query.difficulty;
138+
const difficulty = req.query.difficulty;
121139
const limit = req.query.limit;
122140
const skip = req.query.skip;
123141
const tags = req.query.tags;
@@ -148,7 +166,7 @@ export const trendingCategoryTopics = (_req: Request, res: Response) => {
148166
example: 'localhost:3000/trendingDiscuss?first=20',
149167
});
150168
}
151-
169+
152170
};
153171

154172
export const languageStats = (_req: Request, res: Response) => {
@@ -167,5 +185,5 @@ export const languageStats = (_req: Request, res: Response) => {
167185
example: 'localhost:3000/languageStats?username=uwi',
168186
});
169187
}
170-
188+
171189
};

0 commit comments

Comments
 (0)