-
Controllers
The code of the routes/endpoints. This layer is dumb and should not have any logic. If needed could orchestrate multiple services.
knowledge of: payloads
-
Payloads
It has the structure of the json that we should return on our api calls.
knowledge of: payloads
-
Services
All the business logic belongs here
knowledge of: payloads, models
-
Models
This is the database layer. We should define here the schemas of our mongo documents
knowledge of: models
-
Repos
It has the code that is reponsible to communicate with the database
knowledge of: models
-
Mappers
knowledge of: payloads, models
Note: The "knowledge of:" is very important as it points out the knowledge of each layer. This gives us an advantage of having a clear separation of concerns (SoC) which makes the code easier to extend, maintain.
GET /demo
Get a list of demo items
GET /demo/:id
Get an item by id
POST /demo
Create a demo item
PUT /demo/:id
Update a demo item
DELETE /demo/:id
Delete a demo item