Hi everyone,
I'm currently working on a larger application using NestJS for now everything was going fine but since the project is getting larger and larger and I'm a the only developer working on it I'm at a decision point where I need to find the best way to structure my application modules and etc.
To give you a bit of a background, since I inherited the project which was initially set that it has the following structure:
- /admin -> contains APIs for managing different resources and is behind a AWS Cognito JWT
- /client -> contains API that is accessible to client applications
- /shared -> contains types and interfaces
Now, a problem I'm currently having is that both admin/client do indeed share some services and as an example I can give is that we can have a post.service.ts.
The admin will have the following capabilities:
- List posts
- Approve posts
- Reject posts
The client will have the following capabilities:
- Create posts
- Delete posts
- Edit posts
- Delete posts
Now, if both APIs would have the same response DTO it would be an easy decision where I would have a guard where I would limit actions based on some property on a user which is making the request.
But, both admin and client have different DTOs, as an example
the Admin API would have fields like:
- approvement status (accepted/rejected)
- additional information about the user (e.g. isSuspended)
The client API would return:
- number of comments
- reactions
- etc.
How would be the best way to structure the folders, mappers and etc?