Skip to content
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

80 create endpoints for activity type #107

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

TonyPhan0505
Copy link
Contributor

Created a new schema model for Activity Type. Wrote endpoints for getting all existing activity types, creating a new activity type, updating and deleting an existing activity type.

@TonyPhan0505 TonyPhan0505 linked an issue Nov 24, 2022 that may be closed by this pull request
Copy link
Collaborator

@Sooraj-beep Sooraj-beep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TonyPython0505 Can you also add test suites for these routes? Include creating existing resource and updating new resource along with normal test suites. Reach out if that seems confusing

server/app.js Outdated Show resolved Hide resolved
server/app.js Show resolved Hide resolved
server/controllers/ActivityType.controller.js Outdated Show resolved Hide resolved
server/controllers/ActivityType.controller.js Outdated Show resolved Hide resolved
server/controllers/ActivityType.controller.js Outdated Show resolved Hide resolved
server/controllers/ActivityType.controller.js Outdated Show resolved Hide resolved

/////////////////////////// Routes ///////////////////////////
router.route('/all')
.get(activityTypeController.getAllActivityTypes);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need API_KEY verification called before crud operations can run for all routes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with JWT instead.

if (err) {
return res.status(400).send({message: `Failed to save new activity type. ${err}`});
exports.create = (req, res) => {
if (JWTVerifier.verifyStaffToken(req.body.token, process.env.STAFF_SECRET_KEY)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can be called as middleware where the route is defined. More about middleware functions: https://reflectoring.io/express-middleware/
icard example: https://github.com/UofA-Blueprint/ICard/blob/develop/backend/src/routes/Students.js#L63 (notice how verifyApiKey is called before the actual getStudent controller is called in the route definition).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you decide to make this change, please also change all other endpoints accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create endpoints for Activity_Type
2 participants