Feat: es modules (#139)
* All file imports change from commonjs to es-module * Improved plex error responses back from api * Converted viewHistory to es module * Es-module requires file extension, updated all imports * Fix esmodule not having __dirname defined in scope * Replace dynamic-require with fs readFileSync * Short message service module function is exported as default * Resolved lint issues & ignore import/extension rule until typescript * All tests file imports changed from commonjs to es-module * Import json fixtures with new helper
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
"extends": ["eslint-config-airbnb-base", "plugin:prettier/recommended"],
|
"extends": ["eslint-config-airbnb-base", "plugin:prettier/recommended"],
|
||||||
"plugins": ["mocha"],
|
"plugins": ["mocha"],
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"import/extensions": 0,
|
||||||
"max-classes-per-file": 1,
|
"max-classes-per-file": 1,
|
||||||
"no-empty": [
|
"no-empty": [
|
||||||
2,
|
2,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
"url": "https://www.opensource.org/licenses/mit-license.php"
|
"url": "https://www.opensource.org/licenses/mit-license.php"
|
||||||
},
|
},
|
||||||
"main": "webserver/server.js",
|
"main": "webserver/server.js",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "SEASONED_CONFIG=configurations/production.json NODE_ENV=production node src/webserver/server.js",
|
"start": "SEASONED_CONFIG=configurations/production.json NODE_ENV=production node src/webserver/server.js",
|
||||||
"dev": "SEASONED_CONFIG=configurations/development.json NODE_ENV=development node src/webserver/server.js",
|
"dev": "SEASONED_CONFIG=configurations/development.json NODE_ENV=development node src/webserver/server.js",
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
const Plex = require("src/plex/plex");
|
import Plex from "../src/plex/plexRepository";
|
||||||
const configuration = require("src/config/configuration").getInstance();
|
import establishedDatabase from "../src/database/database";
|
||||||
const plex = new Plex(configuration.get("plex", "ip"));
|
import Configuration from "../src/config/configuration";
|
||||||
const establishedDatabase = require("src/database/database");
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
|
const plex = new Plex(
|
||||||
|
configuration.get("plex", "ip"),
|
||||||
|
configuration.get("plex", "token")
|
||||||
|
);
|
||||||
|
|
||||||
const queries = {
|
const queries = {
|
||||||
getRequestsNotYetInPlex: `SELECT * FROM requests WHERE status = 'requested' OR status = 'downloading'`,
|
getRequestsNotYetInPlex: `SELECT * FROM requests WHERE status = 'requested' OR status = 'downloading'`,
|
||||||
|
|||||||
11
src/cache/redis.js
vendored
11
src/cache/redis.js
vendored
@@ -1,10 +1,11 @@
|
|||||||
const configuration = require("../config/configuration").getInstance();
|
import redis from "redis";
|
||||||
|
import Configuration from "../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
let client;
|
let client;
|
||||||
const mockCache = {};
|
const mockCache = {};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const redis = require("redis"); // eslint-disable-line global-require
|
|
||||||
console.log("Trying to connect with redis.."); // eslint-disable-line no-console
|
console.log("Trying to connect with redis.."); // eslint-disable-line no-console
|
||||||
const host = configuration.get("redis", "host");
|
const host = configuration.get("redis", "host");
|
||||||
const port = configuration.get("redis", "port");
|
const port = configuration.get("redis", "port");
|
||||||
@@ -72,7 +73,7 @@ function get(key) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
get,
|
set,
|
||||||
set
|
get
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
const path = require("path");
|
import fs from "fs";
|
||||||
const Field = require("./field");
|
import path from "path";
|
||||||
|
import { fileURLToPath } from "url";
|
||||||
|
|
||||||
|
import Field from "./field.js";
|
||||||
|
|
||||||
let instance = null;
|
let instance = null;
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.location = Config.determineLocation();
|
this.location = Config.determineLocation();
|
||||||
// eslint-disable-next-line import/no-dynamic-require, global-require
|
this.fields = Config.readFileContents(this.location);
|
||||||
this.fields = require(`${this.location}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static getInstance() {
|
static getInstance() {
|
||||||
@@ -21,6 +25,17 @@ class Config {
|
|||||||
return path.join(__dirname, "..", "..", process.env.SEASONED_CONFIG);
|
return path.join(__dirname, "..", "..", process.env.SEASONED_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static readFileContents(location) {
|
||||||
|
let content = {};
|
||||||
|
try {
|
||||||
|
content = JSON.parse(fs.readFileSync(location, { encoding: "utf-8" }));
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`Error loading configuration file at path: ${location}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
get(section, option) {
|
get(section, option) {
|
||||||
if (
|
if (
|
||||||
this.fields[section] === undefined ||
|
this.fields[section] === undefined ||
|
||||||
@@ -45,4 +60,4 @@ class Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Config;
|
export default Config;
|
||||||
|
|||||||
@@ -12,4 +12,4 @@ class EnvironmentVariables {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = EnvironmentVariables;
|
export default EnvironmentVariables;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const Filters = require("./filters");
|
import Filters from "./filters.js";
|
||||||
const EnvironmentVariables = require("./environmentVariables");
|
import EnvironmentVariables from "./environmentVariables.js";
|
||||||
|
|
||||||
class Field {
|
class Field {
|
||||||
constructor(rawValue, environmentVariables) {
|
constructor(rawValue, environmentVariables) {
|
||||||
@@ -50,4 +50,4 @@ class Field {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Field;
|
export default Field;
|
||||||
|
|||||||
@@ -31,4 +31,4 @@ class Filters {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Filters;
|
export default Filters;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
const configuration = require("../config/configuration").getInstance();
|
import SqliteDatabase from "./sqliteDatabase.js";
|
||||||
const SqliteDatabase = require("./sqliteDatabase");
|
import Configuration from "../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
|
|
||||||
const database = new SqliteDatabase(configuration.get("database", "host"));
|
const database = new SqliteDatabase(configuration.get("database", "host"));
|
||||||
/**
|
/**
|
||||||
@@ -10,4 +12,4 @@ const database = new SqliteDatabase(configuration.get("database", "host"));
|
|||||||
*/
|
*/
|
||||||
Promise.resolve().then(() => database.setUp());
|
Promise.resolve().then(() => database.setUp());
|
||||||
|
|
||||||
module.exports = database;
|
export default database;
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
const fs = require("fs");
|
import fs from "fs";
|
||||||
const path = require("path");
|
import path from "path";
|
||||||
const sqlite3 = require("sqlite3").verbose();
|
import sqlite3 from "sqlite3";
|
||||||
|
import { fileURLToPath } from "url";
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
class SqliteDatabase {
|
class SqliteDatabase {
|
||||||
constructor(host) {
|
constructor(host) {
|
||||||
@@ -115,4 +119,4 @@ class SqliteDatabase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = SqliteDatabase;
|
export default SqliteDatabase;
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ class GitRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = GitRepository;
|
export default GitRepository;
|
||||||
|
|||||||
@@ -15,4 +15,4 @@ class Media {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Media;
|
export default Media;
|
||||||
|
|||||||
@@ -12,4 +12,4 @@ class MediaInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = MediaInfo;
|
export default MediaInfo;
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ class Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Player;
|
export default Player;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
|
|
||||||
const Media = require("./media");
|
import Media from "./media.js";
|
||||||
|
|
||||||
class Plex extends Media {
|
class Plex extends Media {
|
||||||
constructor(
|
constructor(
|
||||||
@@ -30,4 +30,4 @@ class Plex extends Media {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Plex;
|
export default Plex;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
|
import Media from "./media.js";
|
||||||
const Media = require("./media");
|
|
||||||
|
|
||||||
class TMDB extends Media {
|
class TMDB extends Media {
|
||||||
// constructor(...args) {
|
// constructor(...args) {
|
||||||
@@ -45,4 +44,4 @@ class TMDB extends Media {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = TMDB;
|
export default TMDB;
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ class User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = User;
|
export default User;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
const configuration = require("../config/configuration").getInstance();
|
import Configuration from "../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
|
|
||||||
class SMSUnexpectedError extends Error {
|
class SMSUnexpectedError extends Error {
|
||||||
constructor(errorMessage) {
|
constructor(errorMessage) {
|
||||||
@@ -9,7 +11,7 @@ class SMSUnexpectedError extends Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const sendSMS = message => {
|
export default function sendSMS(message) {
|
||||||
const apiKey = configuration.get("sms", "apikey");
|
const apiKey = configuration.get("sms", "apikey");
|
||||||
|
|
||||||
if (!apiKey) {
|
if (!apiKey) {
|
||||||
@@ -35,6 +37,4 @@ const sendSMS = message => {
|
|||||||
.then(response => resolve(response))
|
.then(response => resolve(response))
|
||||||
.catch(error => reject(new SMSUnexpectedError(error)));
|
.catch(error => reject(new SMSUnexpectedError(error)));
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = { sendSMS };
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
const http = require("http");
|
import http from "http";
|
||||||
const { URL } = require("url");
|
import { URL } from "url";
|
||||||
const PythonShell = require("python-shell");
|
import PythonShell from "python-shell";
|
||||||
|
|
||||||
const establishedDatabase = require("../database/database");
|
import establishedDatabase from "../database/database.js";
|
||||||
|
import cache from "../cache/redis.js";
|
||||||
const cache = require("../cache/redis");
|
|
||||||
|
|
||||||
function getMagnetFromURL(url) {
|
function getMagnetFromURL(url) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@@ -46,7 +45,7 @@ async function callPythonAddMagnet(url, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function SearchPiratebay(_query) {
|
export async function SearchPiratebay(_query) {
|
||||||
let query = String(_query);
|
let query = String(_query);
|
||||||
|
|
||||||
if (query?.includes("+")) {
|
if (query?.includes("+")) {
|
||||||
@@ -76,7 +75,7 @@ async function SearchPiratebay(_query) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddMagnet(magnet, name, tmdbId) {
|
export function AddMagnet(magnet, name, tmdbId) {
|
||||||
return new Promise((resolve, reject) =>
|
return new Promise((resolve, reject) =>
|
||||||
callPythonAddMagnet(magnet, (err, results) => {
|
callPythonAddMagnet(magnet, (err, results) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -98,5 +97,3 @@ function AddMagnet(magnet, name, tmdbId) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { SearchPiratebay, AddMagnet };
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const Episode = require("./types/episode");
|
import Episode from "./types/episode.js";
|
||||||
|
|
||||||
function convertPlexToEpisode(plexEpisode) {
|
function convertPlexToEpisode(plexEpisode) {
|
||||||
const episode = new Episode(
|
const episode = new Episode(
|
||||||
@@ -21,4 +21,5 @@ function convertPlexToEpisode(plexEpisode) {
|
|||||||
|
|
||||||
return episode;
|
return episode;
|
||||||
}
|
}
|
||||||
module.exports = convertPlexToEpisode;
|
|
||||||
|
export default convertPlexToEpisode;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const Movie = require("./types/movie");
|
import Movie from "./types/movie.js";
|
||||||
|
|
||||||
function convertPlexToMovie(plexMovie) {
|
function convertPlexToMovie(plexMovie) {
|
||||||
const movie = new Movie(plexMovie.title, plexMovie.year);
|
const movie = new Movie(plexMovie.title, plexMovie.year);
|
||||||
@@ -12,4 +12,4 @@ function convertPlexToMovie(plexMovie) {
|
|||||||
return movie;
|
return movie;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = convertPlexToMovie;
|
export default convertPlexToMovie;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
|
|
||||||
const Plex = require("../media_classes/plex");
|
import Plex from "../media_classes/plex.js";
|
||||||
|
|
||||||
function translateAdded(date_string) {
|
function translateAdded(date_string) {
|
||||||
return new Date(date_string * 1000);
|
return new Date(date_string * 1000);
|
||||||
@@ -32,4 +32,4 @@ function convertPlexToSeasoned(plex) {
|
|||||||
return seasoned;
|
return seasoned;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = convertPlexToSeasoned;
|
export default convertPlexToSeasoned;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const Show = require("./types/show");
|
import Show from "./types/show.js";
|
||||||
|
|
||||||
function convertPlexToShow(plexShow) {
|
function convertPlexToShow(plexShow) {
|
||||||
const show = new Show(plexShow.title, plexShow.year);
|
const show = new Show(plexShow.title, plexShow.year);
|
||||||
@@ -10,4 +10,4 @@ function convertPlexToShow(plexShow) {
|
|||||||
return show;
|
return show;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = convertPlexToShow;
|
export default convertPlexToShow;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
const convertPlexToSeasoned = require("./convertPlexToSeasoned");
|
import convertPlexToSeasoned from "./convertPlexToSeasoned.js";
|
||||||
const convertStreamToMediaInfo = require("./convertStreamToMediaInfo");
|
import convertStreamToMediaInfo from "./convertStreamToMediaInfo.js";
|
||||||
const convertStreamToPlayer = require("./stream/convertStreamToPlayer");
|
import convertStreamToPlayer from "./stream/convertStreamToPlayer.js";
|
||||||
const convertStreamToUser = require("./stream/convertStreamToUser");
|
import convertStreamToUser from "./stream/convertStreamToUser.js";
|
||||||
const ConvertStreamToPlayback = require("./stream/convertStreamToPlayback");
|
import ConvertStreamToPlayback from "./stream/convertStreamToPlayback.js";
|
||||||
|
|
||||||
function convertPlexToStream(plexStream) {
|
function convertPlexToStream(plexStream) {
|
||||||
const stream = convertPlexToSeasoned(plexStream);
|
const stream = convertPlexToSeasoned(plexStream);
|
||||||
@@ -16,4 +16,4 @@ function convertPlexToStream(plexStream) {
|
|||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = convertPlexToStream;
|
export default convertPlexToStream;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const MediaInfo = require("../media_classes/mediaInfo");
|
import MediaInfo from "../media_classes/mediaInfo.js";
|
||||||
|
|
||||||
function convertStreamToMediaInfo(plexStream) {
|
function convertStreamToMediaInfo(plexStream) {
|
||||||
const mediaInfo = new MediaInfo();
|
const mediaInfo = new MediaInfo();
|
||||||
@@ -19,4 +19,4 @@ function convertStreamToMediaInfo(plexStream) {
|
|||||||
return mediaInfo;
|
return mediaInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = convertStreamToMediaInfo;
|
export default convertStreamToMediaInfo;
|
||||||
|
|||||||
@@ -22,4 +22,4 @@ class mailTemplate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = mailTemplate;
|
export default mailTemplate;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const convertPlexToMovie = require("./convertPlexToMovie");
|
import convertPlexToMovie from "./convertPlexToMovie.js";
|
||||||
const convertPlexToShow = require("./convertPlexToShow");
|
import convertPlexToShow from "./convertPlexToShow.js";
|
||||||
const convertPlexToEpisode = require("./convertPlexToEpisode");
|
import convertPlexToEpisode from "./convertPlexToEpisode.js";
|
||||||
const redisCache = require("../cache/redis");
|
import redisCache from "../cache/redis.js";
|
||||||
|
|
||||||
class PlexRequestTimeoutError extends Error {
|
class PlexRequestTimeoutError extends Error {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -227,4 +227,4 @@ class Plex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Plex;
|
export default Plex;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const convertPlexToSeasoned = require("./convertPlexToSeasoned");
|
import convertPlexToSeasoned from "./convertPlexToSeasoned.js";
|
||||||
const convertPlexToStream = require("./convertPlexToStream");
|
import convertPlexToStream from "./convertPlexToStream.js";
|
||||||
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
function addAttributeIfTmdbInPlex(_tmdb, plexResult) {
|
function addAttributeIfTmdbInPlex(_tmdb, plexResult) {
|
||||||
@@ -103,4 +103,4 @@ class PlexRepository {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = PlexRepository;
|
export default PlexRepository;
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
const PlexRepository = require("./plexRepository");
|
import PlexRepository from "./plexRepository.js";
|
||||||
const configuration = require("../config/configuration").getInstance();
|
import TMDB from "../tmdb/tmdb.js";
|
||||||
const TMDB = require("../tmdb/tmdb");
|
import establishedDatabase from "../database/database.js";
|
||||||
const establishedDatabase = require("../database/database");
|
import Configuration from "../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const plexRepository = new PlexRepository(
|
const plexRepository = new PlexRepository(
|
||||||
configuration.get("plex", "ip"),
|
configuration.get("plex", "ip"),
|
||||||
configuration.get("plex", "token")
|
configuration.get("plex", "token")
|
||||||
@@ -128,4 +129,4 @@ class RequestRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = RequestRepository;
|
export default RequestRepository;
|
||||||
|
|||||||
@@ -11,4 +11,4 @@ class convertStreamToPlayback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = convertStreamToPlayback;
|
export default convertStreamToPlayback;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const Player = require("../../media_classes/player");
|
import Player from "../../media_classes/player.js";
|
||||||
|
|
||||||
function convertStreamToPlayer(plexStream) {
|
function convertStreamToPlayer(plexStream) {
|
||||||
const player = new Player(plexStream.device, plexStream.address);
|
const player = new Player(plexStream.device, plexStream.address);
|
||||||
@@ -10,4 +10,4 @@ function convertStreamToPlayer(plexStream) {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = convertStreamToPlayer;
|
export default convertStreamToPlayer;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const User = require("../../media_classes/user");
|
import User from "../../media_classes/user.js";
|
||||||
|
|
||||||
function convertStreamToUser(plexStream) {
|
function convertStreamToUser(plexStream) {
|
||||||
return new User(plexStream.id, plexStream.title);
|
return new User(plexStream.id, plexStream.title);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = convertStreamToUser;
|
export default convertStreamToUser;
|
||||||
|
|||||||
@@ -13,4 +13,4 @@ class Episode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Episode;
|
export default Episode;
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ class Movie {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Movie;
|
export default Movie;
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ class Show {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Show;
|
export default Show;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const assert = require("assert");
|
import assert from "assert";
|
||||||
// const configuration = require("../config/configuration").getInstance();
|
// const configuration = require("../config/configuration").getInstance();
|
||||||
// const TMDB = require("../tmdb/tmdb");
|
// const TMDB = require("../tmdb/tmdb");
|
||||||
const establishedDatabase = require("../database/database");
|
import establishedDatabase from "../database/database.js";
|
||||||
|
|
||||||
// const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
// const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||||
|
|
||||||
@@ -156,4 +156,4 @@ class RequestRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = RequestRepository;
|
export default RequestRepository;
|
||||||
|
|||||||
@@ -45,4 +45,4 @@ function validFilter(filterParam) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { validSort, validFilter };
|
export default { validSort, validFilter };
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const establishedDatabase = require("../database/database");
|
import establishedDatabase from "../database/database.js";
|
||||||
|
|
||||||
class SearchHistoryCreateDatabaseError extends Error {
|
class SearchHistoryCreateDatabaseError extends Error {
|
||||||
constructor(message = "an unexpected error occured", errorResponse = null) {
|
constructor(message = "an unexpected error occured", errorResponse = null) {
|
||||||
@@ -55,4 +55,4 @@ class SearchHistory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = SearchHistory;
|
export default SearchHistory;
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ class Stray {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Stray;
|
export default Stray;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const assert = require("assert");
|
import assert from "assert";
|
||||||
const pythonShell = require("python-shell");
|
import pythonShell from "python-shell";
|
||||||
const Stray = require("./stray");
|
import Stray from "./stray.js";
|
||||||
const establishedDatabase = require("../database/database");
|
import establishedDatabase from "../database/database.js";
|
||||||
|
|
||||||
class StrayRepository {
|
class StrayRepository {
|
||||||
constructor(database) {
|
constructor(database) {
|
||||||
@@ -65,4 +65,4 @@ class StrayRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = StrayRepository;
|
export default StrayRepository;
|
||||||
|
|||||||
@@ -75,4 +75,4 @@ class Tautulli {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Tautulli;
|
export default Tautulli;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const assert = require("assert");
|
import assert from "assert";
|
||||||
const establishedDatabase = require("../database/database");
|
import establishedDatabase from "../database/database.js";
|
||||||
|
|
||||||
class Cache {
|
class Cache {
|
||||||
constructor(database) {
|
constructor(database) {
|
||||||
@@ -45,4 +45,4 @@ class Cache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Cache;
|
export default Cache;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const moviedb = require("km-moviedb");
|
import moviedb from "km-moviedb";
|
||||||
const redisCache = require("../cache/redis");
|
import redisCache from "../cache/redis.js";
|
||||||
|
|
||||||
const { Movie, Show, Person, Credits, ReleaseDates } = require("./types");
|
import { Movie, Show, Person, Credits, ReleaseDates } from "./types.js";
|
||||||
|
|
||||||
class TMDBNotFoundError extends Error {
|
class TMDBNotFoundError extends Error {
|
||||||
constructor(message) {
|
constructor(message) {
|
||||||
@@ -339,4 +339,4 @@ class TMDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = TMDB;
|
export default TMDB;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const Movie = require("./types/movie");
|
import Movie from "./types/movie.js";
|
||||||
const Show = require("./types/show");
|
import Show from "./types/show.js";
|
||||||
const Person = require("./types/person");
|
import Person from "./types/person.js";
|
||||||
const Credits = require("./types/credits");
|
import Credits from "./types/credits.js";
|
||||||
const ReleaseDates = require("./types/releaseDates");
|
import ReleaseDates from "./types/releaseDates.js";
|
||||||
|
|
||||||
module.exports = { Movie, Show, Person, Credits, ReleaseDates };
|
export { Movie, Show, Person, Credits, ReleaseDates };
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
const Movie = require("./movie");
|
import Movie from "./movie.js";
|
||||||
const Show = require("./show");
|
import Show from "./show.js";
|
||||||
|
|
||||||
class CreditedMovie extends Movie {}
|
class CreditedMovie extends Movie {}
|
||||||
class CreditedShow extends Show {}
|
class CreditedShow extends Show {}
|
||||||
@@ -113,4 +113,4 @@ class Credits {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Credits;
|
export default Credits;
|
||||||
|
|||||||
@@ -113,4 +113,4 @@ class Movie {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Movie;
|
export default Movie;
|
||||||
|
|||||||
@@ -69,4 +69,4 @@ class Person {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Person;
|
export default Person;
|
||||||
|
|||||||
@@ -89,4 +89,4 @@ class ReleaseDates {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ReleaseDates;
|
export default ReleaseDates;
|
||||||
|
|||||||
@@ -86,4 +86,4 @@ class Show {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Show;
|
export default Show;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const jwt = require("jsonwebtoken");
|
import jwt from "jsonwebtoken";
|
||||||
const User = require("./user");
|
import User from "./user.js";
|
||||||
|
|
||||||
class Token {
|
class Token {
|
||||||
constructor(user, admin = false, settings = null) {
|
constructor(user, admin = false, settings = null) {
|
||||||
@@ -38,4 +38,4 @@ class Token {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Token;
|
export default Token;
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ class User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = User;
|
export default User;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const assert = require("assert");
|
import assert from "assert";
|
||||||
const establishedDatabase = require("../database/database");
|
import establishedDatabase from "../database/database.js";
|
||||||
|
|
||||||
class LinkPlexUserError extends Error {
|
class LinkPlexUserError extends Error {
|
||||||
constructor(errorMessage = null) {
|
constructor(errorMessage = null) {
|
||||||
@@ -263,4 +263,4 @@ class UserRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = UserRepository;
|
export default UserRepository;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const bcrypt = require("bcrypt");
|
import bcrypt from "bcrypt";
|
||||||
const UserRepository = require("./userRepository");
|
import UserRepository from "./userRepository.js";
|
||||||
|
|
||||||
class UserSecurity {
|
class UserSecurity {
|
||||||
constructor(database) {
|
constructor(database) {
|
||||||
@@ -72,4 +72,4 @@ class UserSecurity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = UserSecurity;
|
export default UserSecurity;
|
||||||
|
|||||||
@@ -1,20 +1,72 @@
|
|||||||
const express = require("express");
|
import express from "express";
|
||||||
const Raven = require("raven");
|
import Raven from "raven";
|
||||||
const cookieParser = require("cookie-parser");
|
import cookieParser from "cookie-parser";
|
||||||
const bodyParser = require("body-parser");
|
import bodyParser from "body-parser";
|
||||||
|
|
||||||
const configuration = require("../config/configuration").getInstance();
|
import Configuration from "../config/configuration.js";
|
||||||
|
|
||||||
const reqTokenToUser = require("./middleware/reqTokenToUser");
|
import reqTokenToUser from "./middleware/reqTokenToUser.js";
|
||||||
const mustBeAuthenticated = require("./middleware/mustBeAuthenticated");
|
import mustBeAuthenticated from "./middleware/mustBeAuthenticated.js";
|
||||||
const mustBeAdmin = require("./middleware/mustBeAdmin");
|
import mustBeAdmin from "./middleware/mustBeAdmin.js";
|
||||||
const mustHaveAccountLinkedToPlex = require("./middleware/mustHaveAccountLinkedToPlex");
|
import mustHaveAccountLinkedToPlex from "./middleware/mustHaveAccountLinkedToPlex.js";
|
||||||
|
|
||||||
const listController = require("./controllers/list/listController");
|
import tautulli from "./controllers/user/viewHistory.js";
|
||||||
const tautulli = require("./controllers/user/viewHistory");
|
import {
|
||||||
const SettingsController = require("./controllers/user/settings");
|
getSettingsController,
|
||||||
const AuthenticatePlexAccountController = require("./controllers/user/authenticatePlexAccount");
|
updateSettingsController
|
||||||
|
} from "./controllers/user/settings.js";
|
||||||
|
import AuthenticatePlexAccountController from "./controllers/user/authenticatePlexAccount.js";
|
||||||
|
|
||||||
|
import UserRegisterController from "./controllers/user/register.js";
|
||||||
|
import UserLoginController from "./controllers/user/login.js";
|
||||||
|
import UserLogoutController from "./controllers/user/logout.js";
|
||||||
|
import UserSearchHistoryController from "./controllers/user/searchHistory.js";
|
||||||
|
import UserRequestsController from "./controllers/user/requests.js";
|
||||||
|
|
||||||
|
import SearchMultiController from "./controllers/search/multiSearch.js";
|
||||||
|
import SearchMovieController from "./controllers/search/movieSearch.js";
|
||||||
|
import SearchShowController from "./controllers/search/showSearch.js";
|
||||||
|
import SearchPersonController from "./controllers/search/personSearch.js";
|
||||||
|
|
||||||
|
import listController from "./controllers/list/listController.js";
|
||||||
|
|
||||||
|
import MovieCreditsController from "./controllers/movie/credits.js";
|
||||||
|
import MovieReleaseDatesController from "./controllers/movie/releaseDates.js";
|
||||||
|
import MovieInfoController from "./controllers/movie/info.js";
|
||||||
|
|
||||||
|
import ShowCreditsController from "./controllers/show/credits.js";
|
||||||
|
import ShowInfoController from "./controllers/show/info.js";
|
||||||
|
|
||||||
|
import PersonCreditsController from "./controllers/person/credits.js";
|
||||||
|
import PersonInfoController from "./controllers/person/info.js";
|
||||||
|
|
||||||
|
import SeasonedAllController from "./controllers/seasoned/readStrays.js";
|
||||||
|
import SeasonedInfoController from "./controllers/seasoned/strayById.js";
|
||||||
|
import SeasonedVerifyController from "./controllers/seasoned/verifyStray.js";
|
||||||
|
|
||||||
|
import PlexSearchController from "./controllers/plex/search.js";
|
||||||
|
import PlexFetchRequestedController from "./controllers/plex/fetchRequested.js";
|
||||||
|
// import PlexRequestsInfo from "./controllers/plex/updateRequested.js";
|
||||||
|
import PlexWatchLinkController from "./controllers/plex/watchDirectLink.js";
|
||||||
|
import PlexHookController from "./controllers/plex/hookDump.js";
|
||||||
|
import PlexSubmitRequestController from "./controllers/plex/submitRequest.js";
|
||||||
|
import PlexRequestInfo from "./controllers/plex/readRequest.js";
|
||||||
|
import PlexSearchRequestController from "./controllers/plex/searchRequest.js";
|
||||||
|
import PlexPlayingController from "./controllers/plex/plexPlaying.js";
|
||||||
|
import PlexSearchMediaController from "./controllers/plex/searchMedia.js";
|
||||||
|
import PlexUpdateRequestedController from "./controllers/plex/updateRequested.js";
|
||||||
|
|
||||||
|
import RequestFetchAllController from "./controllers/request/fetchAllRequests.js";
|
||||||
|
import RequestInfoController from "./controllers/request/getRequest.js";
|
||||||
|
import RequestSubmitController from "./controllers/request/requestTmdbId.js";
|
||||||
|
|
||||||
|
import PirateSearchController from "./controllers/pirate/searchTheBay.js";
|
||||||
|
import PirateAddController from "./controllers/pirate/addMagnet.js";
|
||||||
|
|
||||||
|
import GitDumpController from "./controllers/git/dumpHook.js";
|
||||||
|
import EmojiController from "./controllers/misc/emoji.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
// TODO: Have our raven router check if there is a value, if not don't enable raven.
|
// TODO: Have our raven router check if there is a value, if not don't enable raven.
|
||||||
Raven.config(configuration.get("raven", "DSN")).install();
|
Raven.config(configuration.get("raven", "DSN")).install();
|
||||||
|
|
||||||
@@ -65,30 +117,18 @@ router.get("/", (req, res) => {
|
|||||||
/**
|
/**
|
||||||
* User
|
* User
|
||||||
*/
|
*/
|
||||||
router.post("/v1/user", require("./controllers/user/register"));
|
router.post("/v1/user", UserRegisterController);
|
||||||
router.post("/v1/user/login", require("./controllers/user/login"));
|
router.post("/v1/user/login", UserLoginController);
|
||||||
router.post("/v1/user/logout", require("./controllers/user/logout"));
|
router.post("/v1/user/logout", UserLogoutController);
|
||||||
|
|
||||||
router.get(
|
router.get("/v1/user/settings", mustBeAuthenticated, getSettingsController);
|
||||||
"/v1/user/settings",
|
router.put("/v1/user/settings", mustBeAuthenticated, updateSettingsController);
|
||||||
mustBeAuthenticated,
|
|
||||||
SettingsController.getSettingsController
|
|
||||||
);
|
|
||||||
router.put(
|
|
||||||
"/v1/user/settings",
|
|
||||||
mustBeAuthenticated,
|
|
||||||
SettingsController.updateSettingsController
|
|
||||||
);
|
|
||||||
router.get(
|
router.get(
|
||||||
"/v1/user/search_history",
|
"/v1/user/search_history",
|
||||||
mustBeAuthenticated,
|
mustBeAuthenticated,
|
||||||
require("./controllers/user/searchHistory")
|
UserSearchHistoryController
|
||||||
);
|
|
||||||
router.get(
|
|
||||||
"/v1/user/requests",
|
|
||||||
mustBeAuthenticated,
|
|
||||||
require("./controllers/user/requests")
|
|
||||||
);
|
);
|
||||||
|
router.get("/v1/user/requests", mustBeAuthenticated, UserRequestsController);
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"/v1/user/link_plex",
|
"/v1/user/link_plex",
|
||||||
@@ -125,111 +165,80 @@ router.get(
|
|||||||
/**
|
/**
|
||||||
* Seasoned
|
* Seasoned
|
||||||
*/
|
*/
|
||||||
router.get("/v1/seasoned/all", require("./controllers/seasoned/readStrays"));
|
router.get("/v1/seasoned/all", SeasonedAllController);
|
||||||
router.get(
|
router.get("/v1/seasoned/:strayId", SeasonedInfoController);
|
||||||
"/v1/seasoned/:strayId",
|
router.post("/v1/seasoned/verify/:strayId", SeasonedVerifyController);
|
||||||
require("./controllers/seasoned/strayById")
|
|
||||||
);
|
|
||||||
router.post(
|
|
||||||
"/v1/seasoned/verify/:strayId",
|
|
||||||
require("./controllers/seasoned/verifyStray")
|
|
||||||
);
|
|
||||||
|
|
||||||
router.get("/v2/search/", require("./controllers/search/multiSearch"));
|
router.get("/v2/search/", SearchMultiController);
|
||||||
router.get("/v2/search/movie", require("./controllers/search/movieSearch"));
|
router.get("/v2/search/movie", SearchMovieController);
|
||||||
router.get("/v2/search/show", require("./controllers/search/showSearch"));
|
router.get("/v2/search/show", SearchShowController);
|
||||||
router.get("/v2/search/person", require("./controllers/search/personSearch"));
|
router.get("/v2/search/person", SearchPersonController);
|
||||||
|
|
||||||
router.get("/v2/movie/now_playing", listController.nowPlayingMovies);
|
router.get("/v2/movie/now_playing", listController.nowPlayingMovies);
|
||||||
router.get("/v2/movie/popular", listController.popularMovies);
|
router.get("/v2/movie/popular", listController.popularMovies);
|
||||||
router.get("/v2/movie/top_rated", listController.topRatedMovies);
|
router.get("/v2/movie/top_rated", listController.topRatedMovies);
|
||||||
router.get("/v2/movie/upcoming", listController.upcomingMovies);
|
router.get("/v2/movie/upcoming", listController.upcomingMovies);
|
||||||
router.get("/v2/movie/:id/credits", require("./controllers/movie/credits"));
|
router.get("/v2/movie/:id/credits", MovieCreditsController);
|
||||||
router.get(
|
router.get("/v2/movie/:id/release_dates", MovieReleaseDatesController);
|
||||||
"/v2/movie/:id/release_dates",
|
router.get("/v2/movie/:id", MovieInfoController);
|
||||||
require("./controllers/movie/releaseDates")
|
|
||||||
);
|
|
||||||
router.get("/v2/movie/:id", require("./controllers/movie/info"));
|
|
||||||
|
|
||||||
router.get("/v2/show/now_playing", listController.nowPlayingShows);
|
router.get("/v2/show/now_playing", listController.nowPlayingShows);
|
||||||
router.get("/v2/show/popular", listController.popularShows);
|
router.get("/v2/show/popular", listController.popularShows);
|
||||||
router.get("/v2/show/top_rated", listController.topRatedShows);
|
router.get("/v2/show/top_rated", listController.topRatedShows);
|
||||||
router.get("/v2/show/:id/credits", require("./controllers/show/credits"));
|
router.get("/v2/show/:id/credits", ShowCreditsController);
|
||||||
router.get("/v2/show/:id", require("./controllers/show/info"));
|
router.get("/v2/show/:id", ShowInfoController);
|
||||||
|
|
||||||
router.get("/v2/person/:id/credits", require("./controllers/person/credits"));
|
router.get("/v2/person/:id/credits", PersonCreditsController);
|
||||||
router.get("/v2/person/:id", require("./controllers/person/info"));
|
router.get("/v2/person/:id", PersonInfoController);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plex
|
* Plex
|
||||||
*/
|
*/
|
||||||
router.get("/v2/plex/search", require("./controllers/plex/search"));
|
router.get("/v2/plex/search", PlexSearchController);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List
|
* List
|
||||||
*/
|
*/
|
||||||
router.get("/v1/plex/search", require("./controllers/plex/searchMedia"));
|
router.get("/v1/plex/search", PlexSearchMediaController);
|
||||||
router.get("/v1/plex/playing", require("./controllers/plex/plexPlaying"));
|
router.get("/v1/plex/playing", PlexPlayingController);
|
||||||
router.get("/v1/plex/request", require("./controllers/plex/searchRequest"));
|
router.get("/v1/plex/request", PlexSearchRequestController);
|
||||||
router.get(
|
router.get("/v1/plex/request/:mediaId", PlexRequestInfo);
|
||||||
"/v1/plex/request/:mediaId",
|
router.post("/v1/plex/request/:mediaId", PlexSubmitRequestController);
|
||||||
require("./controllers/plex/readRequest")
|
router.post("/v1/plex/hook", PlexHookController);
|
||||||
);
|
|
||||||
router.post(
|
|
||||||
"/v1/plex/request/:mediaId",
|
|
||||||
require("./controllers/plex/submitRequest")
|
|
||||||
);
|
|
||||||
router.post("/v1/plex/hook", require("./controllers/plex/hookDump"));
|
|
||||||
|
|
||||||
router.get(
|
router.get("/v1/plex/watch-link", mustBeAuthenticated, PlexWatchLinkController);
|
||||||
"/v1/plex/watch-link",
|
|
||||||
mustBeAuthenticated,
|
|
||||||
require("./controllers/plex/watchDirectLink")
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests
|
* Requests
|
||||||
*/
|
*/
|
||||||
|
|
||||||
router.get("/v2/request", require("./controllers/request/fetchAllRequests"));
|
router.get("/v2/request", RequestFetchAllController);
|
||||||
router.get("/v2/request/:id", require("./controllers/request/getRequest"));
|
router.get("/v2/request/:id", RequestInfoController);
|
||||||
router.post("/v2/request", require("./controllers/request/requestTmdbId"));
|
router.post("/v2/request", RequestSubmitController);
|
||||||
router.get(
|
router.get("/v1/plex/requests/all", PlexFetchRequestedController);
|
||||||
"/v1/plex/requests/all",
|
|
||||||
require("./controllers/plex/fetchRequested")
|
|
||||||
);
|
|
||||||
router.put(
|
router.put(
|
||||||
"/v1/plex/request/:requestId",
|
"/v1/plex/request/:requestId",
|
||||||
mustBeAuthenticated,
|
mustBeAuthenticated,
|
||||||
require("./controllers/plex/updateRequested")
|
PlexUpdateRequestedController
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pirate
|
* Pirate
|
||||||
*/
|
*/
|
||||||
router.get(
|
router.get("/v1/pirate/search", mustBeAdmin, PirateSearchController);
|
||||||
"/v1/pirate/search",
|
router.post("/v1/pirate/add", mustBeAdmin, PirateAddController);
|
||||||
mustBeAdmin,
|
|
||||||
require("./controllers/pirate/searchTheBay")
|
|
||||||
);
|
|
||||||
router.post(
|
|
||||||
"/v1/pirate/add",
|
|
||||||
mustBeAdmin,
|
|
||||||
require("./controllers/pirate/addMagnet")
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* git
|
* git
|
||||||
*/
|
*/
|
||||||
router.post("/v1/git/dump", require("./controllers/git/dumpHook"));
|
router.post("/v1/git/dump", GitDumpController);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* misc
|
* misc
|
||||||
*/
|
*/
|
||||||
router.get("/v1/emoji", require("./controllers/misc/emoji"));
|
router.get("/v1/emoji", EmojiController);
|
||||||
|
|
||||||
// REGISTER OUR ROUTES -------------------------------
|
// REGISTER OUR ROUTES -------------------------------
|
||||||
// all of our routes will be prefixed with /api
|
// all of our routes will be prefixed with /api
|
||||||
app.use("/api", router);
|
app.use("/api", router);
|
||||||
|
|
||||||
module.exports = app;
|
export default app;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const GitRepository = require("../../../git/gitRepository");
|
import GitRepository from "../../../git/gitRepository.js";
|
||||||
|
|
||||||
const gitRepository = new GitRepository();
|
const gitRepository = new GitRepository();
|
||||||
|
|
||||||
@@ -9,4 +9,4 @@ function dumpHookController(req, res) {
|
|||||||
.catch(() => res.status(500));
|
.catch(() => res.status(500));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = dumpHookController;
|
export default dumpHookController;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import TMDB from "../../../tmdb/tmdb.js";
|
||||||
const TMDB = require("../../../tmdb/tmdb");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||||
|
|
||||||
// there should be a translate function from query params to
|
// there should be a translate function from query params to
|
||||||
@@ -65,7 +66,7 @@ const popularShows = (req, res) =>
|
|||||||
const topRatedShows = (req, res) =>
|
const topRatedShows = (req, res) =>
|
||||||
fetchTmdbList(req, res, "miscTopRatedTvs", "show");
|
fetchTmdbList(req, res, "miscTopRatedTvs", "show");
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
nowPlayingMovies,
|
nowPlayingMovies,
|
||||||
popularMovies,
|
popularMovies,
|
||||||
topRatedMovies,
|
topRatedMovies,
|
||||||
|
|||||||
@@ -16,12 +16,10 @@ const randomEmoji = () => {
|
|||||||
* @param {Response} res
|
* @param {Response} res
|
||||||
* @returns {Callback}
|
* @returns {Callback}
|
||||||
*/
|
*/
|
||||||
function emojiController(req, res) {
|
export default function emojiController(req, res) {
|
||||||
res.send({
|
res.send({
|
||||||
success: true,
|
success: true,
|
||||||
emoji: randomEmoji(),
|
emoji: randomEmoji(),
|
||||||
message: "Happy emoji-ing! 🌝"
|
message: "Happy emoji-ing! 🌝"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = emojiController;
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import TMDB from "../../../tmdb/tmdb.js";
|
||||||
const TMDB = require("../../../tmdb/tmdb");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||||
|
|
||||||
const movieCreditsController = (req, res) => {
|
const movieCreditsController = (req, res) => {
|
||||||
@@ -19,4 +20,4 @@ const movieCreditsController = (req, res) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = movieCreditsController;
|
export default movieCreditsController;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import TMDB from "../../../tmdb/tmdb.js";
|
||||||
const TMDB = require("../../../tmdb/tmdb");
|
import Plex from "../../../plex/plex.js";
|
||||||
const Plex = require("../../../plex/plex");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||||
const plex = new Plex(configuration.get("plex", "ip"));
|
const plex = new Plex(configuration.get("plex", "ip"));
|
||||||
|
|
||||||
@@ -52,4 +53,4 @@ async function movieInfoController(req, res) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = movieInfoController;
|
export default movieInfoController;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import TMDB from "../../../tmdb/tmdb.js";
|
||||||
const TMDB = require("../../../tmdb/tmdb");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||||
|
|
||||||
const movieReleaseDatesController = (req, res) => {
|
const movieReleaseDatesController = (req, res) => {
|
||||||
@@ -19,4 +20,4 @@ const movieReleaseDatesController = (req, res) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = movieReleaseDatesController;
|
export default movieReleaseDatesController;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import TMDB from "../../../tmdb/tmdb.js";
|
||||||
const TMDB = require("../../../tmdb/tmdb");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||||
|
|
||||||
const personCreditsController = (req, res) => {
|
const personCreditsController = (req, res) => {
|
||||||
@@ -19,4 +20,4 @@ const personCreditsController = (req, res) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = personCreditsController;
|
export default personCreditsController;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import TMDB from "../../../tmdb/tmdb.js";
|
||||||
const TMDB = require("../../../tmdb/tmdb");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,4 +37,4 @@ async function personInfoController(req, res) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = personInfoController;
|
export default personInfoController;
|
||||||
|
|||||||
@@ -5,17 +5,17 @@
|
|||||||
* @Last Modified time: 2017-10-21 15:32:43
|
* @Last Modified time: 2017-10-21 15:32:43
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const PirateRepository = require("../../../pirate/pirateRepository");
|
import { AddMagnet } from "../../../pirate/pirateRepository.js";
|
||||||
|
|
||||||
function addMagnet(req, res) {
|
function addMagnet(req, res) {
|
||||||
const { magnet, name } = req.body;
|
const { magnet, name } = req.body;
|
||||||
const tmdbId = req.body?.tmdb_id;
|
const tmdbId = req.body?.tmdb_id;
|
||||||
|
|
||||||
PirateRepository.AddMagnet(magnet, name, tmdbId)
|
AddMagnet(magnet, name, tmdbId)
|
||||||
.then(result => res.send(result))
|
.then(result => res.send(result))
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
res.status(500).send({ success: false, message: error.message });
|
res.status(500).send({ success: false, message: error.message });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = addMagnet;
|
export default addMagnet;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* @Last Modified time: 2018-02-26 19:56:32
|
* @Last Modified time: 2018-02-26 19:56:32
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const PirateRepository = require("../../../pirate/pirateRepository");
|
import { SearchPiratebay } from "../../../pirate/pirateRepository.js";
|
||||||
// const pirateRepository = new PirateRepository();
|
// const pirateRepository = new PirateRepository();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,7 +17,7 @@ const PirateRepository = require("../../../pirate/pirateRepository");
|
|||||||
function updateRequested(req, res) {
|
function updateRequested(req, res) {
|
||||||
const { query, page, type } = req.query;
|
const { query, page, type } = req.query;
|
||||||
|
|
||||||
PirateRepository.SearchPiratebay(query, page, type)
|
SearchPiratebay(query, page, type)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
res.send({ success: true, results: result });
|
res.send({ success: true, results: result });
|
||||||
})
|
})
|
||||||
@@ -26,4 +26,4 @@ function updateRequested(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = updateRequested;
|
export default updateRequested;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const RequestRepository = require("../../../plex/requestRepository");
|
import RequestRepository from "../../../plex/requestRepository.js";
|
||||||
|
|
||||||
const requestRepository = new RequestRepository();
|
const requestRepository = new RequestRepository();
|
||||||
|
|
||||||
@@ -26,4 +26,4 @@ function fetchRequestedController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = fetchRequestedController;
|
export default fetchRequestedController;
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ function hookDumpController(req, res) {
|
|||||||
res.status(200);
|
res.status(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = hookDumpController;
|
export default hookDumpController;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
const PlexRepository = require("../../../plex/plexRepository");
|
import PlexRepository from "../../../plex/plexRepository.js";
|
||||||
const configuration = require("../../../config/configuration").getInstance();
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
|
|
||||||
const plexRepository = new PlexRepository(
|
const plexRepository = new PlexRepository(
|
||||||
configuration.get("plex", "ip"),
|
configuration.get("plex", "ip"),
|
||||||
@@ -17,4 +19,4 @@ function playingController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = playingController;
|
export default playingController;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const RequestRepository = require("../../../plex/requestRepository");
|
import RequestRepository from "../../../plex/requestRepository.js";
|
||||||
|
|
||||||
const requestRepository = new RequestRepository();
|
const requestRepository = new RequestRepository();
|
||||||
|
|
||||||
@@ -21,4 +21,4 @@ function readRequestController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = readRequestController;
|
export default readRequestController;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import Plex from "../../../plex/plex.js";
|
||||||
const Plex = require("../../../plex/plex");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
|
|
||||||
const plex = new Plex(configuration.get("plex", "ip"));
|
const plex = new Plex(configuration.get("plex", "ip"));
|
||||||
|
|
||||||
@@ -28,4 +30,4 @@ function searchPlexController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = searchPlexController;
|
export default searchPlexController;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
const PlexRepository = require("../../../plex/plexRepository");
|
import PlexRepository from "../../../plex/plexRepository.js";
|
||||||
const configuration = require("../../../config/configuration").getInstance();
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
|
|
||||||
const plexRepository = new PlexRepository(
|
const plexRepository = new PlexRepository(
|
||||||
configuration.get("plex", "ip"),
|
configuration.get("plex", "ip"),
|
||||||
@@ -33,4 +35,4 @@ function searchMediaController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = searchMediaController;
|
export default searchMediaController;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const SearchHistory = require("../../../searchHistory/searchHistory");
|
import SearchHistory from "../../../searchHistory/searchHistory.js";
|
||||||
const Cache = require("../../../tmdb/cache");
|
import Cache from "../../../tmdb/cache.js";
|
||||||
const RequestRepository = require("../../../plex/requestRepository");
|
import RequestRepository from "../../../plex/requestRepository.js";
|
||||||
|
|
||||||
const cache = new Cache();
|
const cache = new Cache();
|
||||||
const requestRepository = new RequestRepository(cache);
|
const requestRepository = new RequestRepository(cache);
|
||||||
@@ -21,4 +21,4 @@ function searchRequestController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = searchRequestController;
|
export default searchRequestController;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import RequestRepository from "../../../request/request.js";
|
||||||
const RequestRepository = require("../../../request/request");
|
import TMDB from "../../../tmdb/tmdb.js";
|
||||||
const TMDB = require("../../../tmdb/tmdb");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||||
const request = new RequestRepository();
|
const request = new RequestRepository();
|
||||||
|
|
||||||
@@ -57,4 +58,4 @@ function submitRequestController(req, res) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = submitRequestController;
|
export default submitRequestController;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const RequestRepository = require("../../../plex/requestRepository");
|
import RequestRepository from "../../../plex/requestRepository.js";
|
||||||
|
|
||||||
const requestRepository = new RequestRepository();
|
const requestRepository = new RequestRepository();
|
||||||
|
|
||||||
@@ -23,4 +23,4 @@ function updateRequested(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = updateRequested;
|
export default updateRequested;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import Plex from "../../../plex/plex.js";
|
||||||
const Plex = require("../../../plex/plex");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const plex = new Plex(configuration.get("plex", "ip"));
|
const plex = new Plex(configuration.get("plex", "ip"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,4 +26,4 @@ function watchDirectLink(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = watchDirectLink;
|
export default watchDirectLink;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const RequestRepository = require("../../../request/request");
|
import RequestRepository from "../../../request/request.js";
|
||||||
|
|
||||||
const request = new RequestRepository();
|
const request = new RequestRepository();
|
||||||
|
|
||||||
@@ -24,4 +24,4 @@ function fetchAllRequests(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = fetchAllRequests;
|
export default fetchAllRequests;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const RequestRepository = require("../../../request/request");
|
import RequestRepository from "../../../request/request.js";
|
||||||
|
|
||||||
const request = new RequestRepository();
|
const request = new RequestRepository();
|
||||||
|
|
||||||
@@ -37,4 +37,4 @@ function fetchAllRequests(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = fetchAllRequests;
|
export default fetchAllRequests;
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import TMDB from "../../../tmdb/tmdb.js";
|
||||||
const TMDB = require("../../../tmdb/tmdb");
|
import RequestRepository from "../../../request/request.js";
|
||||||
const RequestRepository = require("../../../request/request");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
// import sendSMS from "../../../notifications/sms.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||||
const request = new RequestRepository();
|
const request = new RequestRepository();
|
||||||
// const { sendSMS } = require("src/notifications/sms");
|
|
||||||
|
|
||||||
const tmdbMovieInfo = id => {
|
const tmdbMovieInfo = id => {
|
||||||
return tmdb.movieInfo(id);
|
return tmdb.movieInfo(id);
|
||||||
@@ -65,4 +66,4 @@ function requestTmdbIdController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = requestTmdbIdController;
|
export default requestTmdbIdController;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import TMDB from "../../../tmdb/tmdb.js";
|
||||||
const TMDB = require("../../../tmdb/tmdb");
|
import SearchHistory from "../../../searchHistory/searchHistory.js";
|
||||||
const SearchHistory = require("../../../searchHistory/searchHistory");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||||
const searchHistory = new SearchHistory();
|
const searchHistory = new SearchHistory();
|
||||||
|
|
||||||
@@ -33,4 +34,4 @@ function movieSearchController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = movieSearchController;
|
export default movieSearchController;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import TMDB from "../../../tmdb/tmdb.js";
|
||||||
const TMDB = require("../../../tmdb/tmdb");
|
import SearchHistory from "../../../searchHistory/searchHistory.js";
|
||||||
const SearchHistory = require("../../../searchHistory/searchHistory");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||||
const searchHistory = new SearchHistory();
|
const searchHistory = new SearchHistory();
|
||||||
|
|
||||||
@@ -33,4 +34,4 @@ function multiSearchController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = multiSearchController;
|
export default multiSearchController;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import TMDB from "../../../tmdb/tmdb.js";
|
||||||
const TMDB = require("../../../tmdb/tmdb");
|
import SearchHistory from "../../../searchHistory/searchHistory.js";
|
||||||
const SearchHistory = require("../../../searchHistory/searchHistory");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||||
const searchHistory = new SearchHistory();
|
const searchHistory = new SearchHistory();
|
||||||
|
|
||||||
@@ -33,4 +34,4 @@ function personSearchController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = personSearchController;
|
export default personSearchController;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
const SearchHistory = require("../../../searchHistory/searchHistory");
|
import TMDB from "../../../tmdb/tmdb.js";
|
||||||
const configuration = require("../../../config/configuration").getInstance();
|
import SearchHistory from "../../../searchHistory/searchHistory.js";
|
||||||
const TMDB = require("../../../tmdb/tmdb");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||||
const searchHistory = new SearchHistory();
|
const searchHistory = new SearchHistory();
|
||||||
|
|
||||||
@@ -35,4 +36,4 @@ function showSearchController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = showSearchController;
|
export default showSearchController;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const StrayRepository = require("../../../seasoned/strayRepository");
|
import StrayRepository from "../../../seasoned/strayRepository.js";
|
||||||
|
|
||||||
const strayRepository = new StrayRepository();
|
const strayRepository = new StrayRepository();
|
||||||
|
|
||||||
@@ -14,4 +14,4 @@ function readStraysController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = readStraysController;
|
export default readStraysController;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const StrayRepository = require("../../../seasoned/strayRepository");
|
import StrayRepository from "../../../seasoned/strayRepository.js";
|
||||||
|
|
||||||
const strayRepository = new StrayRepository();
|
const strayRepository = new StrayRepository();
|
||||||
|
|
||||||
@@ -15,4 +15,4 @@ function strayByIdController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = strayByIdController;
|
export default strayByIdController;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const StrayRepository = require("../../../seasoned/strayRepository");
|
import StrayRepository from "../../../seasoned/strayRepository.js";
|
||||||
|
|
||||||
const strayRepository = new StrayRepository();
|
const strayRepository = new StrayRepository();
|
||||||
|
|
||||||
@@ -15,4 +15,4 @@ function verifyStrayController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = verifyStrayController;
|
export default verifyStrayController;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import TMDB from "../../../tmdb/tmdb.js";
|
||||||
const TMDB = require("../../../tmdb/tmdb");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||||
|
|
||||||
const showCreditsController = (req, res) => {
|
const showCreditsController = (req, res) => {
|
||||||
@@ -19,4 +20,4 @@ const showCreditsController = (req, res) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = showCreditsController;
|
export default showCreditsController;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import TMDB from "../../../tmdb/tmdb.js";
|
||||||
const TMDB = require("../../../tmdb/tmdb");
|
import Plex from "../../../plex/plex.js";
|
||||||
const Plex = require("../../../plex/plex");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
const tmdb = new TMDB(configuration.get("tmdb", "apiKey"));
|
||||||
const plex = new Plex(configuration.get("plex", "ip"));
|
const plex = new Plex(configuration.get("plex", "ip"));
|
||||||
|
|
||||||
@@ -47,4 +48,4 @@ async function showInfoController(req, res) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = showInfoController;
|
export default showInfoController;
|
||||||
|
|||||||
@@ -1,45 +1,39 @@
|
|||||||
const FormData = require("form-data");
|
import FormData from "form-data";
|
||||||
const UserRepository = require("../../../user/userRepository");
|
import UserRepository from "../../../user/userRepository.js";
|
||||||
|
|
||||||
const userRepository = new UserRepository();
|
const userRepository = new UserRepository();
|
||||||
|
|
||||||
class PlexAuthenticationError extends Error {
|
class PlexAuthenticationError extends Error {
|
||||||
constructor(errorResponse, statusCode) {
|
constructor(errorResponse) {
|
||||||
const message =
|
const message =
|
||||||
"Unexptected error while authenticating to plex signin api. View error response.";
|
"Unexptected error while authenticating to plex signin api. View error response.";
|
||||||
super(message);
|
super(message);
|
||||||
|
|
||||||
this.errorResponse = errorResponse;
|
this.errorResponse = errorResponse;
|
||||||
this.statusCode = statusCode;
|
this.statusCode = 500;
|
||||||
this.success = false;
|
this.success = false;
|
||||||
|
this.source = "plex";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleError(error, res) {
|
class PlexUnauthorizedError extends Error {
|
||||||
const status = error?.status;
|
constructor(errorResponse) {
|
||||||
let { message, source } = error;
|
const message = "Unauthorized. Please check plex credentials.";
|
||||||
|
super(message);
|
||||||
|
|
||||||
if (status && message) {
|
this.errorResponse = errorResponse;
|
||||||
if (status === 401) {
|
this.statusCode = 401;
|
||||||
message = "Unauthorized. Please check plex credentials.";
|
this.success = false;
|
||||||
source = "plex";
|
this.source = "plex";
|
||||||
}
|
|
||||||
|
|
||||||
res.status(status).send({ success: false, message, source });
|
|
||||||
} else {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log("caught authenticate plex account controller error", error);
|
|
||||||
res.status(500).send({
|
|
||||||
message:
|
|
||||||
"An unexpected error occured while authenticating your account with plex",
|
|
||||||
source
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleResponse(response) {
|
function handleResponse(response) {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new PlexAuthenticationError(response.statusText, response.status);
|
if (response?.status === 401)
|
||||||
|
throw new PlexUnauthorizedError(response?.statusText);
|
||||||
|
|
||||||
|
throw new PlexAuthenticationError(response?.statusText);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.json();
|
return response.json();
|
||||||
@@ -80,7 +74,16 @@ function link(req, res) {
|
|||||||
"Successfully authenticated and linked plex account with seasoned request."
|
"Successfully authenticated and linked plex account with seasoned request."
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.catch(error => handleError(error, res));
|
.catch(error =>
|
||||||
|
res.status(error?.statusCode || 500).send({
|
||||||
|
message:
|
||||||
|
error?.message ||
|
||||||
|
"Unexptected error occured while linking plex account",
|
||||||
|
success: error?.success || false,
|
||||||
|
source: error?.source,
|
||||||
|
errorResponse: error?.errorResponse
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function unlink(req, res) {
|
function unlink(req, res) {
|
||||||
@@ -94,10 +97,16 @@ function unlink(req, res) {
|
|||||||
message: "Successfully unlinked plex account from seasoned request."
|
message: "Successfully unlinked plex account from seasoned request."
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.catch(error => handleError(error, res));
|
.catch(error =>
|
||||||
|
res.status(error?.statusCode || 500).send({
|
||||||
|
message:
|
||||||
|
error?.message ||
|
||||||
|
"Unexptected error occured while unlinking plex account",
|
||||||
|
success: error?.success || false,
|
||||||
|
source: error?.source,
|
||||||
|
errorResponse: error?.errorResponse
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
export default { link, unlink };
|
||||||
link,
|
|
||||||
unlink
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
const User = require("../../../user/user");
|
import User from "../../../user/user.js";
|
||||||
const Token = require("../../../user/token");
|
import Token from "../../../user/token.js";
|
||||||
const UserSecurity = require("../../../user/userSecurity");
|
import UserSecurity from "../../../user/userSecurity.js";
|
||||||
const UserRepository = require("../../../user/userRepository");
|
import UserRepository from "../../../user/userRepository.js";
|
||||||
const configuration = require("../../../config/configuration").getInstance();
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const secret = configuration.get("authentication", "secret");
|
const secret = configuration.get("authentication", "secret");
|
||||||
const userSecurity = new UserSecurity();
|
const userSecurity = new UserSecurity();
|
||||||
const userRepository = new UserRepository();
|
const userRepository = new UserRepository();
|
||||||
@@ -54,4 +55,4 @@ async function loginController(req, res) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = loginController;
|
export default loginController;
|
||||||
|
|||||||
@@ -13,4 +13,4 @@ async function logoutController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = logoutController;
|
export default logoutController;
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
const User = require("../../../user/user");
|
import User from "../../../user/user.js";
|
||||||
const Token = require("../../../user/token");
|
import Token from "../../../user/token.js";
|
||||||
const UserSecurity = require("../../../user/userSecurity");
|
import UserSecurity from "../../../user/userSecurity.js";
|
||||||
const configuration = require("../../../config/configuration").getInstance();
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const secret = configuration.get("authentication", "secret");
|
const secret = configuration.get("authentication", "secret");
|
||||||
const userSecurity = new UserSecurity();
|
const userSecurity = new UserSecurity();
|
||||||
|
|
||||||
@@ -42,4 +43,4 @@ function registerController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = registerController;
|
export default registerController;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const RequestRepository = require("../../../plex/requestRepository");
|
import RequestRepository from "../../../plex/requestRepository.js";
|
||||||
|
|
||||||
const requestRepository = new RequestRepository();
|
const requestRepository = new RequestRepository();
|
||||||
|
|
||||||
@@ -25,4 +25,4 @@ function requestsController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = requestsController;
|
export default requestsController;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const SearchHistory = require("../../../searchHistory/searchHistory");
|
import SearchHistory from "../../../searchHistory/searchHistory.js";
|
||||||
|
|
||||||
const searchHistory = new SearchHistory();
|
const searchHistory = new SearchHistory();
|
||||||
|
|
||||||
@@ -21,4 +21,4 @@ function historyController(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = historyController;
|
export default historyController;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const UserRepository = require("../../../user/userRepository");
|
import UserRepository from "../../../user/userRepository.js";
|
||||||
|
|
||||||
const userRepository = new UserRepository();
|
const userRepository = new UserRepository();
|
||||||
/**
|
/**
|
||||||
@@ -7,7 +7,7 @@ const userRepository = new UserRepository();
|
|||||||
* @param {Response} res
|
* @param {Response} res
|
||||||
* @returns {Callback}
|
* @returns {Callback}
|
||||||
*/
|
*/
|
||||||
const getSettingsController = (req, res) => {
|
export function getSettingsController(req, res) {
|
||||||
const username = req.loggedInUser ? req.loggedInUser.username : null;
|
const username = req.loggedInUser ? req.loggedInUser.username : null;
|
||||||
|
|
||||||
userRepository
|
userRepository
|
||||||
@@ -18,9 +18,9 @@ const getSettingsController = (req, res) => {
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
res.status(404).send({ success: false, message: error.message });
|
res.status(404).send({ success: false, message: error.message });
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
const updateSettingsController = (req, res) => {
|
export function updateSettingsController(req, res) {
|
||||||
const username = req.loggedInUser ? req.loggedInUser.username : null;
|
const username = req.loggedInUser ? req.loggedInUser.username : null;
|
||||||
|
|
||||||
// const idempotencyKey = req.headers("Idempotency-Key"); // TODO implement better transactions
|
// const idempotencyKey = req.headers("Idempotency-Key"); // TODO implement better transactions
|
||||||
@@ -35,9 +35,4 @@ const updateSettingsController = (req, res) => {
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
res.status(404).send({ success: false, message: error.message });
|
res.status(404).send({ success: false, message: error.message });
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
getSettingsController,
|
|
||||||
updateSettingsController
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const configuration = require("../../../config/configuration").getInstance();
|
import Tautulli from "../../../tautulli/tautulli.js";
|
||||||
const Tautulli = require("../../../tautulli/tautulli");
|
import Configuration from "../../../config/configuration.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const apiKey = configuration.get("tautulli", "apiKey");
|
const apiKey = configuration.get("tautulli", "apiKey");
|
||||||
const ip = configuration.get("tautulli", "ip");
|
const ip = configuration.get("tautulli", "ip");
|
||||||
const port = configuration.get("tautulli", "port");
|
const port = configuration.get("tautulli", "port");
|
||||||
@@ -101,9 +102,9 @@ function userViewHistoryController(req, res) {
|
|||||||
// const username = user.username;
|
// const username = user.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
watchTimeStatsController,
|
watchTimeStatsController,
|
||||||
getPlaysByDaysController,
|
|
||||||
getPlaysByDayOfWeekController,
|
getPlaysByDayOfWeekController,
|
||||||
|
getPlaysByDaysController,
|
||||||
userViewHistoryController
|
userViewHistoryController
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const establishedDatabase = require("../../database/database");
|
import establishedDatabase from "../../database/database.js";
|
||||||
|
|
||||||
// eslint-disable-next-line consistent-return
|
// eslint-disable-next-line consistent-return
|
||||||
const mustBeAdmin = (req, res, next) => {
|
const mustBeAdmin = (req, res, next) => {
|
||||||
@@ -28,4 +28,4 @@ const mustBeAdmin = (req, res, next) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = mustBeAdmin;
|
export default mustBeAdmin;
|
||||||
|
|||||||
@@ -10,4 +10,4 @@ const mustBeAuthenticated = (req, res, next) => {
|
|||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = mustBeAuthenticated;
|
export default mustBeAuthenticated;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const establishedDatabase = require("../../database/database");
|
import establishedDatabase from "../../database/database.js";
|
||||||
|
|
||||||
/* eslint-disable consistent-return */
|
/* eslint-disable consistent-return */
|
||||||
const mustHaveAccountLinkedToPlex = (req, res, next) => {
|
const mustHaveAccountLinkedToPlex = (req, res, next) => {
|
||||||
@@ -33,4 +33,4 @@ const mustHaveAccountLinkedToPlex = (req, res, next) => {
|
|||||||
};
|
};
|
||||||
/* eslint-enable consistent-return */
|
/* eslint-enable consistent-return */
|
||||||
|
|
||||||
module.exports = mustHaveAccountLinkedToPlex;
|
export default mustHaveAccountLinkedToPlex;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
/* eslint-disable no-param-reassign */
|
/* eslint-disable no-param-reassign */
|
||||||
const configuration = require("../../config/configuration").getInstance();
|
import Configuration from "../../config/configuration.js";
|
||||||
const Token = require("../../user/token");
|
import Token from "../../user/token.js";
|
||||||
|
|
||||||
|
const configuration = Configuration.getInstance();
|
||||||
const secret = configuration.get("authentication", "secret");
|
const secret = configuration.get("authentication", "secret");
|
||||||
|
|
||||||
// Token example:
|
// Token example:
|
||||||
@@ -25,4 +26,4 @@ const reqTokenToUser = (req, res, next) => {
|
|||||||
return next();
|
return next();
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = reqTokenToUser;
|
export default reqTokenToUser;
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
const config = require("../config/configuration").getInstance();
|
import Configuration from "../config/configuration.js";
|
||||||
const app = require("./app");
|
import app from "./app.js";
|
||||||
|
|
||||||
module.exports = app.listen(config.get("webserver", "port"), () => {
|
const configuration = Configuration.getInstance();
|
||||||
|
|
||||||
|
export default app.listen(configuration.get("webserver", "port"), () => {
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
console.log("seasonedAPI");
|
console.log("seasonedAPI");
|
||||||
console.log(`Database is located at ${config.get("database", "host")}`);
|
console.log(
|
||||||
console.log(`Webserver is listening on ${config.get("webserver", "port")}`);
|
`Database is located at ${configuration.get("database", "host")}`
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
`Webserver is listening on ${configuration.get("webserver", "port")}`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
const redisCache = require("../../src/cache/redis");
|
import redisCache from "../../src/cache/redis.js";
|
||||||
|
|
||||||
function createCacheEntry(key, value) {
|
export default function createCacheEntry(key, value) {
|
||||||
return redisCache.set(key, value);
|
return redisCache.set(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = createCacheEntry;
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user