Moved contents of seasoned_api up to root folder

This commit is contained in:
2022-08-19 01:03:27 +02:00
parent 0efc109992
commit 56262a45c8
134 changed files with 885 additions and 32 deletions

View File

@@ -0,0 +1,32 @@
const SearchHistory = require("../../../searchHistory/searchHistory");
const configuration = require("../../../config/configuration").getInstance();
const TMDB = require("../../../tmdb/tmdb");
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
const searchHistory = new SearchHistory();
/**
* Controller: Search for shows by query and pagey
* @param {Request} req http request variable
* @param {Response} res
* @returns {Callback}
*/
function showSearchController(req, res) {
const { query, page, adult } = req.query;
const username = req.loggedInUser ? req.loggedInUser.username : null;
const includeAdult = adult == "true" ? true : false;
if (username) {
searchHistory.create(username, query);
}
return tmdb
.showSearch(query, page, includeAdult)
.then(shows => {
res.send(shows);
})
.catch(error => {
res.status(500).send({ success: false, message: error.message });
});
}
module.exports = showSearchController;