Normalize to double quotes across all files with Prettier
This commit is contained in:
1 parent
73bff72cec
commit
a5659cf4c8
190 files changed
+9523
-8859
No files matched your search
@@ -1,16 +1,15 @@
|
||||
const EntryRating = require('../models/EntryRating');
|
||||
const collectionManager = require('../services/collectionManager');
|
||||
const entryManager = require('../services/entryManager');
|
||||
const EntryRating = require("../models/EntryRating");
|
||||
const collectionManager = require("../services/collectionManager");
|
||||
const entryManager = require("../services/entryManager");
|
||||
const entryService = require("../services/entryService");
|
||||
const tmdbService = require('../services/tmdbService');
|
||||
const asyncWrapper = require('../utils/asyncWrapper');
|
||||
const tmdbService = require("../services/tmdbService");
|
||||
const asyncWrapper = require("../utils/asyncWrapper");
|
||||
|
||||
const _collectionManager = collectionManager;
|
||||
const _entryManager = entryManager;
|
||||
const _entryService = entryService;
|
||||
|
||||
class EntryController {
|
||||
|
||||
constructor() {
|
||||
if (!EntryController.instance) {
|
||||
EntryController.instance = this;
|
||||
@@ -37,7 +36,10 @@ class EntryController {
|
||||
fetchAndSaveNewEntry = asyncWrapper(async (req, res) => {
|
||||
const { tmdb_id, is_tvserie } = req.body;
|
||||
|
||||
const createdEntry = await _entryManager.fetchAndSaveNewEntry(tmdb_id, is_tvserie);
|
||||
const createdEntry = await _entryManager.fetchAndSaveNewEntry(
|
||||
tmdb_id,
|
||||
is_tvserie,
|
||||
);
|
||||
|
||||
res.status(201).json(createdEntry);
|
||||
});
|
||||
@@ -46,7 +48,11 @@ class EntryController {
|
||||
const { id } = req.params;
|
||||
const { entryData } = req.body;
|
||||
|
||||
const updatedEntry = await _entryService.updateEntryById(id, entryData, true);
|
||||
const updatedEntry = await _entryService.updateEntryById(
|
||||
id,
|
||||
entryData,
|
||||
true,
|
||||
);
|
||||
|
||||
res.status(201).json(updatedEntry);
|
||||
});
|
||||
@@ -56,7 +62,10 @@ class EntryController {
|
||||
const { id } = req.params;
|
||||
const { entryRatings } = req.body;
|
||||
|
||||
const updatedEntryRatings = await _entryService.updateEntryRatings(id, entryRatings);
|
||||
const updatedEntryRatings = await _entryService.updateEntryRatings(
|
||||
id,
|
||||
entryRatings,
|
||||
);
|
||||
|
||||
res.status(200).json(updatedEntryRatings);
|
||||
});
|
||||
@@ -66,7 +75,10 @@ class EntryController {
|
||||
const { id } = req.params;
|
||||
const { entryIds } = req.body;
|
||||
|
||||
const updatedEntryIds = await _entryService.updateEntryRatings(id, entryIds);
|
||||
const updatedEntryIds = await _entryService.updateEntryRatings(
|
||||
id,
|
||||
entryIds,
|
||||
);
|
||||
|
||||
res.status(200).json(updatedEntryIds);
|
||||
});
|
||||
@@ -90,10 +102,10 @@ class EntryController {
|
||||
getEntrySeasons = asyncWrapper(async (req, res) => {
|
||||
const { id } = req.params;
|
||||
|
||||
const seasons = await _entryService.getEntrySeasons(id)
|
||||
const seasons = await _entryService.getEntrySeasons(id);
|
||||
|
||||
if (seasons.length == 0) {
|
||||
res.status(204).json({ message: 'Provided entry has no seasons' });
|
||||
res.status(204).json({ message: "Provided entry has no seasons" });
|
||||
}
|
||||
|
||||
res.status(200).json(seasons);
|
||||
@@ -110,7 +122,7 @@ class EntryController {
|
||||
refrechEntry = asyncWrapper(async (req, res, next) => {
|
||||
const { id } = req.params;
|
||||
|
||||
const entry = await _entryManager.refrechEntryById(id)
|
||||
const entry = await _entryManager.refrechEntryById(id);
|
||||
res.status(201).json(entry);
|
||||
});
|
||||
|
||||
@@ -132,7 +144,8 @@ class EntryController {
|
||||
const { type } = req.params;
|
||||
const { page } = req.query;
|
||||
const data = await tmdbService.fetchTrending(type, page || 1);
|
||||
if (!data) return res.status(500).json({ message: 'Failed to fetch trending data' });
|
||||
if (!data)
|
||||
return res.status(500).json({ message: "Failed to fetch trending data" });
|
||||
res.status(200).json(data);
|
||||
});
|
||||
|
||||
@@ -141,16 +154,19 @@ class EntryController {
|
||||
const { type } = req.params;
|
||||
const { page } = req.query;
|
||||
const data = await tmdbService.fetchPopular(type, page || 1);
|
||||
if (!data) return res.status(500).json({ message: 'Failed to fetch popular data' });
|
||||
if (!data)
|
||||
return res.status(500).json({ message: "Failed to fetch popular data" });
|
||||
res.status(200).json(data);
|
||||
});
|
||||
|
||||
// * GET - TMDB SEARCH
|
||||
getTmdbSearch = asyncWrapper(async (req, res) => {
|
||||
const { query, page } = req.query;
|
||||
if (!query) return res.status(400).json({ message: 'Query parameter is required' });
|
||||
if (!query)
|
||||
return res.status(400).json({ message: "Query parameter is required" });
|
||||
const data = await tmdbService.searchMulti(query, page || 1);
|
||||
if (!data) return res.status(500).json({ message: 'Failed to search TMDB' });
|
||||
if (!data)
|
||||
return res.status(500).json({ message: "Failed to search TMDB" });
|
||||
res.status(200).json(data);
|
||||
});
|
||||
|
||||
@@ -159,7 +175,10 @@ class EntryController {
|
||||
const { type } = req.params;
|
||||
const { page } = req.query;
|
||||
const data = await tmdbService.fetchTopRated(type, page || 1);
|
||||
if (!data) return res.status(500).json({ message: 'Failed to fetch top rated data' });
|
||||
if (!data)
|
||||
return res
|
||||
.status(500)
|
||||
.json({ message: "Failed to fetch top rated data" });
|
||||
res.status(200).json(data);
|
||||
});
|
||||
|
||||
@@ -167,16 +186,18 @@ class EntryController {
|
||||
getTmdbUpcoming = asyncWrapper(async (req, res) => {
|
||||
const { page } = req.query;
|
||||
const data = await tmdbService.fetchUpcoming(page || 1);
|
||||
if (!data) return res.status(500).json({ message: 'Failed to fetch upcoming data' });
|
||||
if (!data)
|
||||
return res.status(500).json({ message: "Failed to fetch upcoming data" });
|
||||
res.status(200).json(data);
|
||||
});
|
||||
|
||||
// * GET - TMDB PREVIEW (fetch details without saving to library)
|
||||
getTmdbPreview = asyncWrapper(async (req, res) => {
|
||||
const { type, tmdbId } = req.params;
|
||||
const is_tvserie = type === 'tv';
|
||||
const is_tvserie = type === "tv";
|
||||
const data = await tmdbService.fetchEntryData(tmdbId, is_tvserie);
|
||||
if (!data) return res.status(404).json({ message: 'Entry not found on TMDB' });
|
||||
if (!data)
|
||||
return res.status(404).json({ message: "Entry not found on TMDB" });
|
||||
|
||||
// Fetch credits in parallel
|
||||
const creditsData = await tmdbService.fetchEntryCredits(tmdbId, is_tvserie);
|
||||
@@ -187,10 +208,10 @@ class EntryController {
|
||||
for (const c of creditsData.cast) {
|
||||
credits.push({
|
||||
id: c.credit_id || c.id,
|
||||
cast_type: 'cast',
|
||||
cast_type: "cast",
|
||||
character: is_tvserie
|
||||
? (c.roles?.[0]?.character || c.character || null)
|
||||
: (c.character || null),
|
||||
? c.roles?.[0]?.character || c.character || null
|
||||
: c.character || null,
|
||||
people_id: c.id,
|
||||
people: {
|
||||
id: c.id,
|
||||
@@ -208,9 +229,12 @@ class EntryController {
|
||||
title: data.title || data.name,
|
||||
original_title: data.original_title || data.original_name || null,
|
||||
release_date: data.release_date || data.first_air_date || null,
|
||||
runtime: data.runtime || (data.episode_run_time?.[0]) || null,
|
||||
runtime: data.runtime || data.episode_run_time?.[0] || null,
|
||||
storyline: data.overview || null,
|
||||
country: data.origin_country?.[0] || data.production_countries?.[0]?.iso_3166_1 || null,
|
||||
country:
|
||||
data.origin_country?.[0] ||
|
||||
data.production_countries?.[0]?.iso_3166_1 ||
|
||||
null,
|
||||
is_tvseries: is_tvserie,
|
||||
status: data.status || null,
|
||||
poster_path: data.poster_path || null,
|
||||
|
||||
Reference in new issue
Block a user