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

[Team Offline Merge] updates models + created and updates routes #44

Merged
merged 73 commits into from
Oct 13, 2023

Conversation

sofiiagran
Copy link
Contributor

@sofiiagran sofiiagran commented Oct 12, 2023

Description

last updated 19:57 12/10/23 : added extra error handling as well as testing error handling

We have changed and created some new routes and updated models

Changes

We have updated models so they follow the structure on Miro.
We have commented out all the routes we are not using.

The new routes are found in courseRoutes and are related to fetching courses and sections, as well as subscribing to course.

We also did some modifications in the authRoute so that the user id is stored in addition to mail and name from before.

Related Issues

Not really.

Checklist

  • [ yes ] Code has been tested locally and passes all relevant tests.
  • [ yes ] Documentation has been updated to reflect the changes, if applicable.
  • [ yes ] Code follows the established coding style and guidelines of the project.
  • [ yes ] All new and existing tests related to the changes have passed.
  • [ yes ] Any necessary dependencies or new packages have been properly documented.
  • [ yes ] Pull request title and description are clear and descriptive.
  • [ yes ] Reviewers have been assigned to the pull request.
  • [ yes ] Any potential security implications have been considered and addressed.
  • [ yes ] Performance impact of the changes has been evaluated, if relevant.

Notes for Reviewers

Changed the naming of some .spec files in the application / content-creator application folder, since the tests are from last year and all the tests fail. they are now named with notInUseTest_ at the beginning and removed the .specs to avoid testing them for now.

All routes have been tested in the test folder

Copy link
Contributor

@Mafusn Mafusn left a comment

Choose a reason for hiding this comment

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

Looks good, only minor changes

/api/courses in index.js, and moved user subscription to user tests
@sofiiagran sofiiagran requested a review from Mafusn October 12, 2023 11:32
routes/userRoutes.js Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs some tests for handling errors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:((((

Copy link
Contributor Author

Choose a reason for hiding this comment

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

har lavet sindssygt mange tests for handling errors

Copy link
Contributor

@Mafusn Mafusn left a comment

Choose a reason for hiding this comment

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

Looks good, only needs some more test cases for errors, and maybe take a look at the file errorCodes.js in the helpers folder. It would be great to implement them as soon as possible, there is a readme file in the resources repo for them. Quick note, why are you adding an .idea folder.

@sofiiagran sofiiagran requested a review from Mafusn October 12, 2023 17:57
@sofiiagran
Copy link
Contributor Author

sofiiagran commented Oct 12, 2023

lots of error handling and tests of error handling added :))

Made sure everything is following microservices REST API guidelines

These files were added to the .gitignore, they should not be.
Copy link
Contributor

@Havkost Havkost left a comment

Choose a reason for hiding this comment

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

Approved

Great job, especially on the tests 👍

We should discuss how we format actions in our API routes, but I don't think that discussion should block a merge now.

.gitignore Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Great that you're using the error codes! Remember to add the to ERRORS.md in the resources repo

/*** SUBSCRIPTION ROUTES ***/

// Subscribe to course
router.post('/:id/subscribe', async (req, res) => {
Copy link
Contributor

@Havkost Havkost Oct 12, 2023

Choose a reason for hiding this comment

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

Right now our api guidelines specify that actions like subscribe should be formatted as e.g.
/couses/some-id:subscribe.

We should either change the guidelines or follow them. Maybe this is a question for the integration team?

How to add colon in express endpoints:
expressjs/express#3857 (comment)

Copy link
Contributor Author

@sofiiagran sofiiagran Oct 13, 2023

Choose a reason for hiding this comment

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

Jeg tror ikke subscribe er "action" som beskrevet i API guidelines, siden den opdaterer (updates) modellen til user: defor tror jeg det går under denne definition:
DO NOT use an action operation when the operation behavior could reasonably be defined as one of the standard REST Create, Read, Update, Delete, or List operations.

Copy link
Contributor Author

@sofiiagran sofiiagran Oct 13, 2023

Choose a reason for hiding this comment

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

altså subscribe tror jeg ikke er action som beskrevet her: Performing an Action
The REST specification is used to model the state of a resource, and is primarily intended to handle CRUD (Create, Read, Update, Delete) operations. However, many services require the ability to perform an action on a resource, e.g. getting the thumbnail of an image or rebooting a VM. It is also sometimes useful to perform an action on a collection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

og chatGPT mente at courses/:id/subscribe var rigtigt

routes/courseRoutes.js Show resolved Hide resolved
},
E0007: {
code: 'E0007',
message: 'No sections not found'
Copy link
Contributor

Choose a reason for hiding this comment

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

"No sections not found" maybe "No sections found"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed



// Checks if user is subscribed to a specific course
router.get('', async (req, res) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this route correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

@Mafusn Mafusn left a comment

Choose a reason for hiding this comment

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

Only two very small comments

@sofiiagran sofiiagran requested a review from Mafusn October 13, 2023 08:53
Copy link
Contributor

@Mafusn Mafusn left a comment

Choose a reason for hiding this comment

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

Great work!

@sofiiagran sofiiagran merged commit 350852f into dev Oct 13, 2023
2 checks passed
@Jatewo Jatewo mentioned this pull request Oct 18, 2023
9 tasks
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.

6 participants