When creating method routes, do we need to keep an order?
There is a certain specificity on how we arrange our routes based on the route and then on the method. We want to keep the order in which requests can come in, that is:
1st: the root route
This is most commonly only a GET request to the server in general, if we talk about a web app that has a server on its own like Facebook for example, the root route request will fetch all necessary static pages and data to give us the login or home page (depending on what the browser has already stored).
2nd: specific routes, ie:
These are the routes that will directly relate to content in bulk, getting all the animals or expressions and creating a new animal or expression. it is important that for each one of these routes you will follow it by its longer paths, for example, setting up:
and after, having the following specific route:
which leads us to
3rd: longer routes, ie.:
this mainly comprises of three functions, Read one object (
GET by id), Update (
PUT) or Delete (as we guessed
That said, there is no greater reason to this than structure since express matches route and method, but it makes it more legible and easier to debug if we ever encounter any issues.