foyzulkarim / mern-video-streaming

MERN Video Streaming is a cutting-edge, open-source platform for video streaming, offering a comprehensive, full-stack solution utilizing the latest MERN stack technologies.
MIT License
182 stars 63 forks source link

Wrong Method Call from Video Controller in GET Details of Video #68

Closed ysnarafat closed 1 year ago

ysnarafat commented 1 year ago

https://github.com/foyzulkarim/mern-video-streaming/blob/main/server/src/modules/models/video/controller.js

app.get(`${BASE_URL}/detail/:id`, async (req, res) => {
    console.log(`GET`, req.params);
    const video = await updateViewCount(req.params.id);
    if (video instanceof Error) {
      return res.status(400).json(JSON.parse(video.message));
    }
    res.send(video);
  });

Instead it should be

app.get(`${BASE_URL}/detail/:id`, async (req, res) => {
    console.log(`GET`, req.params);
    const video = await getById(req.params.id);
    if (video instanceof Error) {
      return res.status(400).json(JSON.parse(video.message));
    }
    res.send(video);
  });
aninda052 commented 1 year ago

@ysnarafat we have a feature to increase video count when a user watch a video. updateViewCount function will increase the video count and return the video object. if we use getById function, it'll just return the video object.

foyzulkarim commented 1 year ago

Not applicable.