-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactor/rest like endpoints #180
Conversation
Check the documentation preview: https://64bc161bc1e594100f3b7140--niaefeup-backend-docs.netlify.app |
Some endpoints are somewhat rule-breakers. I think having different operations to handle the team and project memberships is somewhat of an anti-pattern in REST terms. Having the operations seems to be way too imperative, almost resembling Remote Procedure Calls (RPC).
This is me being pedantic at this point, as I see value in these exceptions, making the endpoints easier to interact with. |
Check the documentation preview: https://64bc1af5ee3868146d26cade--niaefeup-backend-docs.netlify.app |
I haven't reviewed but I want to warn that after #139 this PR needs to address the API on the new endpoints. Let's discuss the team decision in the next meeting |
I think that it's not pedantic at all and you approach is simpler imo, it simplifies the backend by reducing the number of endpoints, by having the side-effect of sometimes making more api calls (eg.: to add a team member, you have to get the current list and then make the request to rewrite the list of members with the new member. In most situations there's no additional overhead, but in some cases it'll add a request of overhead). I think we need more opinion on this cc: @MRita443 |
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.
Good job with the refactor!
Thoughts/Answers to your comment:
- As for adding members to the teams, I think we could change to POST /events/{id}/team and pass an id in the body, resembling the creation of a new team member. I think this is more RESTful and keeps the API simpler to use
- As for project archival/unarchival, if we want to be very strict about REST norms then we could erase it since we can change it using the regular PUT. The reason I proposed these endpoints at the time was that I could see a clear purpose for them (e.g. clicking an archive button instead of editing a form that updates the project). We can also say that updating and archiving entities are different things (independently of implementation), there seems to be a discussion on this https://stackoverflow.com/questions/16201905/restful-archiving-of-entities-in-webapi
Personaly, I prefer having an exception to REST and keeping the API easily understandable, just like GitHub and Reddit do in some cases.
@DisplayName("GET events?category={category}") | ||
inner class GetEventsByCategory { |
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 all these tests should be moved into GetEvents
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.
This got me thinking that we might want to have more filters on the BE (e.g. archived posts) but I think we can wait to see how FE wants to implement filters
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 all these tests should be moved into
GetEvents
Will do!
|
#64 was merged, could you please refactor the endpoints too? It's the exact same thing as adding team members |
@Sirze01 can you look into this please? |
b445b21
to
80b7e39
Compare
80b7e39
to
f281ac5
Compare
Updated the PR description. |
Check the documentation preview: https://652175c3fcd9760d2429564a--niaefeup-backend-docs.netlify.app |
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.
really small detail!
src/main/kotlin/pt/up/fe/ni/website/backend/controller/ProjectController.kt
Outdated
Show resolved
Hide resolved
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.
Great job!
Check the documentation preview: https://65248e239ed0e50b7944894c--niaefeup-backend-docs.netlify.app |
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, great work 🚀
Check the documentation preview: |
Closes #143
First of all kudos to @BrunoRosendo for the great groundwork.
This PR refactors some of the endpoints being used and adds support for URL queries in the documentation, as, as of now, some endpoints rely on URL queries to filter the returned contents:
Next is a list of the affected endpoints:
accounts
auth
events
generations
posts
projects
Review checklist