When working with a NestJS RESTful API using Mongoose, what is the commonly accepted and effective approach to managing relationships between resources? My project closely follows a similar structure found here, with the only difference being my use of repositories instead of entities.
For example, in the context of a Cat
repository (as outlined in the NestJS documentation), I may also have a Food
repository that includes various types of food, including those suitable for cats.
If I need to retrieve the food associated with a specific type
of Cat while adhering to RESTful API conventions, my endpoint would be:
/cat/:type/foods
This approach seems quite clear and I find it appealing.
In my actual application, the architecture looks like this: https://i.sstatic.net/rhxtI.png
As illustrated, each resource has connections to others at some point. So, what should the path look like for each resource when accessing them by ID or through their relations?
Resources referenced: