-
Notifications
You must be signed in to change notification settings - Fork 5
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
Update QuestionService Endpoints and Documentation #33
Conversation
KhoonSun47
commented
Sep 23, 2024
- Documentation:
- Updated README.md with information on the new and updated endpoints.
- Added detailed descriptions and examples for the add, update, delete and get endpoints.
- Endpoints:
- Added Endpoints for get, update, add and delete.
- Database:
- Added a script for user creation during the initial setup of the database.
- questionController.ts: Implemented new get endpoint for retrieving questions. - questionModel.ts: Updated `Difficulty` enum to `Hard` enum. - questionRoutes.ts: Added new routes for handling get requests. - helper.ts: Added helper function for improved error handling.
- Update `getQuestions`: Include optional parameters for filtering. - Update `getQuestionsByParameters`: Add randomisation. - Add `addQuestion`: New endpoint to add a question. - Add `updateQuestion`: New Endpoint to update an existing question. - Add `deleteQuestion`: New Endpoint to delete a question.
- Improved upon the current GET with updated details - Add new details on ADD, UPDATE and DELETE Questions
- Add response body for success for getQuestionByParameters - Update case insensitive for topics
- README.md: Added examples for ease of copy and paste - questionController.ts: Added additional checking for update
- README.md: Update the documentation with new cmd statements - MongoDB Settings: Add an initialisation script to create user with required credentials when the MongoDB container is first started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems rather thorough, should be good after some minor fixes and figuring out autoincrement IDs!
|
||
### Parameters: | ||
|
||
- `limit` (Optional) - The number of questions to be returned. If not provided, default limit is 1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I thought we were excluding the limit
field from this endpoint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I included the limit field because it allows us to control the number of questions returned after filtering, which I think is useful for admins. It also enables us to randomly select questions within that limit.
Then for users, the default is set to one random question, so I don't think they will be affected by this.
const query: any = {}; | ||
|
||
if (title) { | ||
query.title = { $regex: `^${title as string}$`, $options: 'i' }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why regex is being used here for exact (case-insensitive) matches? Given that the server would be the one calling the service, don't think this is necessary (and it would result in slower DB queries).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhh okay I get what you mean already, I will make the change.
|
||
- `title` (Optional) - Filter by question title. | ||
- `description` (Optional) - Filter by question description. | ||
- `topics` (Optional) - Filter by topics associated with the questions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make more sense for them to pass in an array of topics? Or if you prefer the comma separated method, could you specify it in the README?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, I understand what you mean. Hm, I think I will just use the comma separated method and I will write the consideration in README.
- Edit the README based on comments - Edit the EndPoints functionality based on comments
- README.md: Update details on the functionality of Endpoints - index.ts: Initialise counter for questionID when start database - questionController.ts: Update getQuestions and getQuestionsByParameters to return empty array if not found - questionController.ts: Add counter for ID when addQuestion - counterModel.ts & sequence.ts: Add function to initialise and retrieve counter
…ay2425s1-project-g03 into init-question * 'init-question' of https://github.com/KhoonSun47/cs3219-ay2425s1-project-g03: Update prettier to format html files (CS3219-AY2425S1#34) Fix linting Add .env to .gitignore Add async animations provider Change primeflex import from css to scss Add PrimeFlex Add ng lint fix Add PrimeNG
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM all the endpoints are working