ProjectSakura / Mirai

A website to stream Anime and read Manga for free.. Everything is scraped from sources online and we don't need to actually host any videos or images.
Other
48 stars 31 forks source link

End point controllers refactoring #7

Closed singhayushh closed 3 years ago

singhayushh commented 3 years ago

I am willing to take up this issue.

I have another suggestion regarding the code modularity. Currently the controller functions for each of the routes are written right inside the route definition. Example:

router.get("/", function (req, res, next) {
  request(
    "https://www.gogoanime1.com/search/topSearch?q=" + req.query.q,
    (error, response, html) => {
      res.send(response.body);
    }
  );
});

A good convention to follow is to create a controllers/ directory and have all these controller functions (let's call the above handler function as topSearchHandler) in there so that the api end point just has to call the function:

router.get("/", topSearchHandler)

Originally posted by @singhayushh in https://github.com/ProjectSakura/Mirai/issues/2#issuecomment-794932074

singhayushh commented 3 years ago

Since the two issues (#2 and #7) are closely related, I have worked on them simultaneously. All changes have been made and I'll be creating a Pull Request very soon.

ArunTeltia commented 3 years ago

Kudos to you @singhayushh for this PR , the code is already looking much more organized🙌

singhayushh commented 3 years ago

Kudos to you @singhayushh for this PR , the code is already looking much more organized

Thank you! Happy to have helped ✌🏼