chaynHQ/bloom-backend

Create GET /subscription_user endpoint

Closed this issue · 5 comments

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

@eleanorreem Can I please take on this issue? thanks.

Thank you @Tim-Quattrochi you have been assigned this issue!
Please follow the directions in our Contributing Guide. We look forward to reviewing your pull request shortly ✨


Support Chayn's mission? ⭐ Please star this repo to help us find more contributors like you!
Learn more about Chayn here and explore our projects. 🌸

@eleanorreem Just wanted to get some clarification. You said the the service should just return the name, and the controller should return the 'GetSubscriptionUsersDto', this is my return response right now:
Screenshot 2024-08-10 at 11 41 15 PM

Progress: Need to refactor, test more.

Screenshot 2024-08-11 at 5 38 34 AM

@eleanorreem Just wanted to get some clarification. You said the the service should just return the name, and the controller should return the 'GetSubscriptionUsersDto', this is my return response right now: Screenshot 2024-08-10 at 11 41 15 PM

Hi @Tim-Quattrochi thank you for your contribution! Great question. Eleanor is off right now until Monday, I will ping her to come here and answer your question. Thanks for your patience!