chai-backend icon indicating copy to clipboard operation
chai-backend copied to clipboard

Subscription controllers

Open GRajKumar2512 opened this issue 1 year ago • 3 comments

i am not sure whether these controller functions are at there correct place:

const router = Router();
router.use(verifyJWT); // Apply verifyJWT middleware to all routes in this file

router
  .route("/c/:channelId")
  .get(getSubscribedChannels)
  .post(toggleSubscription);

router.route("/u/:subscriberId").get(getUserChannelSubscribers);

because in the controllers files: getSubscribedChannels is fetching the subscriberId and getUserChannelSubscribers is fetching the channelId

GRajKumar2512 avatar Jan 23 '24 06:01 GRajKumar2512

Yes, When I am working on it. I also saw this problem. So, then we can change them as our requirement. But, It is good to raise this issue for future concern. Will it affect other functions or not? please update here. If I find one I will update.

AdityaChaudhary3 avatar Jan 23 '24 14:01 AdityaChaudhary3

Can't you include the getSubscribedChannels inside the post() method as a middleware.

SaunakNandi avatar Feb 02 '24 04:02 SaunakNandi

I have update the subscription router and now it is working as excepted:

updated code 👍🏼

router .route("/c/:channelId") .get(getUserChannelSubscribers) .post(toggleSubscription);

// router.route("/u/:subscriberId").get(getUserChannelSubscribers); router.route("/u/:subscriberId").get(getSubscribedChannels);

anurag2169 avatar Jul 19 '24 08:07 anurag2169