Created one function for searching for different tmdb lists. This replaces 4 endpoints so we have a single way of searching for lists.

This commit is contained in:
2017-10-23 14:58:52 +02:00
parent d836dd01d3
commit c48db517ac
3 changed files with 89 additions and 225 deletions

View File

@@ -0,0 +1,26 @@
const configuration = require('src/config/configuration').getInstance();
const Cache = require('src/tmdb/cache');
const TMDB = require('src/tmdb/tmdb');
const cache = new Cache();
const tmdb = new TMDB(cache, configuration.get('tmdb', 'apiKey'));
/**
* Controller: Retrieve nowplaying movies / now airing shows
* @param {Request} req http request variable
* @param {Response} res
* @returns {Callback}
*/
function listSearchController(req, res) {
const listname = req.params.listname;
const { type, id, page } = req.query;
console.log(listname, type, id, page)
tmdb.listSearch(listname, type, id, page)
.then((results) => {
res.send(results);
}).catch((error) => {
res.status(404).send({ success: false, error: error.message });
});
}
module.exports = listSearchController;