Skip to content

feat: new API to get raw version of selected question. #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
24 changes: 21 additions & 3 deletions src/leetCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -148,7 +166,7 @@ export const trendingCategoryTopics = (_req: Request, res: Response) => {
example: 'localhost:3000/trendingDiscuss?first=20',
});
}

};

export const languageStats = (_req: Request, res: Response) => {
Expand All @@ -167,5 +185,5 @@ export const languageStats = (_req: Request, res: Response) => {
example: 'localhost:3000/languageStats?username=uwi',
});
}

};