bloom-backend
bloom-backend copied to clipboard
Create GET /subscription_user endpoint
Overview
We want to start breaking up the GET /user/me request and only fetch information on the pages it is needed. This is starting with subscriptions. We also are misusing types across the site so we want to improve the ways of transferring data. Note that we don't want any DTOs to be used in the service, only in the controllers. We are also phasing out all ITypes such as ISubscriptionUser. All formatting needs to happen in the controller. I have labelled this ticket as advanced, not because of the complexity, but because of the confidence needed in controller/service interactions and appropriate types.
Action Items
- [ ] get familiar with Nestjs best practices with the resources below
- [ ] Create a service method that return an array of SubscriptionEntities for a user. Please note, you will want to be returning the subscription name i.e. whatsapp, not just the subscription_user table. this might look like
SubscriptionUserService.getSubscriptions(userId)
- [ ] Create a GetSubscriptionUsersDto which returns an array of GetSubscriptionUserDto (you might want to make 2 dtos, one that returns an array of the other)
- [ ] The GetSubscriptionUserDto needs to have the following properties:
- [ ] ``` { id: string; subscriptionId: string; subscriptionName: string; subscriptionInfo: string; createdAt: Date; cancelledAt: Date | null; }
- [ ] Create a GET /subscription_user endpoint that returns all the subscriptions of the authenticated user. It should return a GetSubscriptionUsersDto. Please use NestJs recommended guidance to build the DTO rather than using the pattern that is in use on the site as it is incorrect. Formatting the return DTO needs to happen in the controller
### Resources
- https://docs.nestjs.com/openapi/types-and-parameters
- https://docs.nestjs.com/openapi/mapped-types
- https://medium.com/ayuth/proper-way-to-create-response-dto-in-nest-js-2d58b9e42bf9