Changed tmdb constructor to have apiKey as first parameter. If cache is not defined we use redis.

This commit is contained in:
2020-04-08 22:54:19 +02:00
parent 578eff30fb
commit 815aaedffb
12 changed files with 17 additions and 39 deletions

View File

@@ -27,9 +27,10 @@ const tmdbErrorResponse = (error, typeString=undefined) => {
}
class TMDB {
constructor(cache, apiKey, tmdbLibrary) {
this.cache = cache || redisCache;
constructor(apiKey, cache, tmdbLibrary) {
this.tmdbLibrary = tmdbLibrary || moviedb(apiKey);
this.cache = cache || redisCache;
this.cacheTags = {
multiSearch: 'mus',
movieSearch: 'mos',

View File

@@ -1,8 +1,6 @@
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'));
const tmdb = new TMDB(configuration.get('tmdb', 'apiKey'));
// there should be a translate function from query params to
// tmdb list that is valid. Should it be a helper function or does it

View File

@@ -1,9 +1,7 @@
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'));
const tmdb = new TMDB(configuration.get('tmdb', 'apiKey'));
const movieCreditsController = (req, res) => {
const movieId = req.params.id;
@@ -23,4 +21,4 @@ const movieCreditsController = (req, res) => {
})
}
module.exports = movieCreditsController;
module.exports = movieCreditsController;

View File

@@ -1,9 +1,7 @@
const configuration = require('src/config/configuration').getInstance();
const Cache = require('src/tmdb/cache');
const TMDB = require('src/tmdb/tmdb');
const Plex = require('src/plex/plex');
const cache = new Cache();
const tmdb = new TMDB(cache, configuration.get('tmdb', 'apiKey'));
const tmdb = new TMDB(configuration.get('tmdb', 'apiKey'));
const plex = new Plex(configuration.get('plex', 'ip'));
function handleError(error, res) {

View File

@@ -1,9 +1,7 @@
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'));
const tmdb = new TMDB(configuration.get('tmdb', 'apiKey'));
const movieReleaseDatesController = (req, res) => {
const movieId = req.params.id;
@@ -23,4 +21,4 @@ const movieReleaseDatesController = (req, res) => {
})
}
module.exports = movieReleaseDatesController;
module.exports = movieReleaseDatesController;

View File

@@ -1,8 +1,6 @@
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'));
const tmdb = new TMDB(configuration.get('tmdb', 'apiKey'));
/**
* Controller: Retrieve information for a person

View File

@@ -1,9 +1,7 @@
const configuration = require('src/config/configuration').getInstance();
const Cache = require('src/tmdb/cache');
const TMDB = require('src/tmdb/tmdb');
const SearchHistory = require('src/searchHistory/searchHistory');
const cache = new Cache();
const tmdb = new TMDB(cache, configuration.get('tmdb', 'apiKey'));
const tmdb = new TMDB(configuration.get('tmdb', 'apiKey'));
const searchHistory = new SearchHistory();
/**

View File

@@ -1,9 +1,7 @@
const configuration = require('src/config/configuration').getInstance();
const Cache = require('src/tmdb/cache');
const TMDB = require('src/tmdb/tmdb');
const SearchHistory = require('src/searchHistory/searchHistory');
const cache = new Cache();
const tmdb = new TMDB(cache, configuration.get('tmdb', 'apiKey'));
const tmdb = new TMDB(configuration.get('tmdb', 'apiKey'));
const searchHistory = new SearchHistory();
function checkAndCreateJsonResponse(result) {

View File

@@ -1,9 +1,7 @@
const configuration = require('src/config/configuration').getInstance();
const Cache = require('src/tmdb/cache');
const TMDB = require('src/tmdb/tmdb');
const SearchHistory = require('src/searchHistory/searchHistory');
const cache = new Cache();
const tmdb = new TMDB(cache, configuration.get('tmdb', 'apiKey'));
const tmdb = new TMDB(configuration.get('tmdb', 'apiKey'));
const searchHistory = new SearchHistory();
/**

View File

@@ -1,9 +1,7 @@
const SearchHistory = require('src/searchHistory/searchHistory');
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'));
const tmdb = new TMDB(configuration.get('tmdb', 'apiKey'));
const searchHistory = new SearchHistory();
/**

View File

@@ -1,9 +1,6 @@
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'));
const tmdb = new TMDB(configuration.get('tmdb', 'apiKey'));
const showCreditsController = (req, res) => {
const showId = req.params.id;
@@ -23,4 +20,4 @@ const showCreditsController = (req, res) => {
})
}
module.exports = showCreditsController;
module.exports = showCreditsController;

View File

@@ -1,9 +1,7 @@
const configuration = require('src/config/configuration').getInstance();
const Cache = require('src/tmdb/cache');
const TMDB = require('src/tmdb/tmdb');
const Plex = require('src/plex/plex');
const cache = new Cache();
const tmdb = new TMDB(cache, configuration.get('tmdb', 'apiKey'));
const tmdb = new TMDB(configuration.get('tmdb', 'apiKey'));
const plex = new Plex(configuration.get('plex', 'ip'));
function handleError(error, res) {