Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create GET /subscription_user endpoint #429

Closed
4 of 5 tasks
eleanorreem opened this issue May 23, 2024 · 5 comments
Closed
4 of 5 tasks

Create GET /subscription_user endpoint #429

eleanorreem opened this issue May 23, 2024 · 5 comments
Assignees
Labels
complexity: advanced Time needed to do this ticket will be large e.g. 2-3+ days help wanted Extra attention is needed maintenance Maintenance / chore work state: approved Ready to go. Not blocked or pending.
Milestone

Comments

@eleanorreem
Copy link
Contributor

eleanorreem commented May 23, 2024

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 eleanorreem added complexity: advanced Time needed to do this ticket will be large e.g. 2-3+ days maintenance Maintenance / chore work state: approved Ready to go. Not blocked or pending. labels May 23, 2024
@kyleecodes kyleecodes added this to the 02. Roadmaps milestone May 27, 2024
@kyleecodes kyleecodes added the help wanted Extra attention is needed label Jul 23, 2024
@Tim-Quattrochi
Copy link
Contributor

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

Copy link

github-actions bot commented Aug 5, 2024

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. 🌸

@Tim-Quattrochi
Copy link
Contributor

@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

@Tim-Quattrochi
Copy link
Contributor

Progress: Need to refactor, test more.

Screenshot 2024-08-11 at 5 38 34 AM

@kyleecodes
Copy link
Member

@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!

eleanorreem added a commit that referenced this issue Sep 10, 2024
* refactor: add GetSubscriptionUserDto and getUserSubscriptions endpoint [WIP][Refactor][Tests]

* refactor: remove userId property from GetSubscriptionUserDto, fixed overly nested response.

* test: add getUserSubscriptions service tests

* refactor: add try catch to getSubscriptions service.

* chore: abstract serialization into utils

* Remove GetSubscriptionUsersDto

* Update get-subscription-user.dto.ts

---------

Co-authored-by: eleanorreem <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity: advanced Time needed to do this ticket will be large e.g. 2-3+ days help wanted Extra attention is needed maintenance Maintenance / chore work state: approved Ready to go. Not blocked or pending.
Projects
None yet
Development

No branches or pull requests

3 participants