Normalize to double quotes across all files with Prettier

This commit is contained in:
X4Lo committed 2026-06-21 22:28:08 +01:00
1 parent 73bff72cec
commit a5659cf4c8
190 files changed
+9523 -8859

No files matched your search

+61 -58
View File
@@ -1,104 +1,108 @@
const express = require('express');
const express = require("express");
const entryRouter = express.Router();
const { entryPicturesUpload } = require('../services/mutlerStorageLocations');
const Entry = require('../models/Entry');
const Media = require('../models/Media');
const { logToFile } = require('../services/logService');
const { entryPicturesUpload } = require("../services/mutlerStorageLocations");
const Entry = require("../models/Entry");
const Media = require("../models/Media");
const { logToFile } = require("../services/logService");
const entryController = require('../controllers/entryController');
const mediaOptimizerService = require('../services/mediaOptimizerService');
const entryController = require("../controllers/entryController");
const mediaOptimizerService = require("../services/mediaOptimizerService");
// ! /entries
// ! TMDB PROXY ROUTES (must be before /:id to avoid matching)
entryRouter.get('/tmdb/trending/:type', entryController.getTmdbTrending);
entryRouter.get('/tmdb/popular/:type', entryController.getTmdbPopular);
entryRouter.get('/tmdb/top-rated/:type', entryController.getTmdbTopRated);
entryRouter.get('/tmdb/upcoming/movie', entryController.getTmdbUpcoming);
entryRouter.get('/tmdb/search', entryController.getTmdbSearch);
entryRouter.get('/tmdb/preview/:type/:tmdbId', entryController.getTmdbPreview);
entryRouter.get("/tmdb/trending/:type", entryController.getTmdbTrending);
entryRouter.get("/tmdb/popular/:type", entryController.getTmdbPopular);
entryRouter.get("/tmdb/top-rated/:type", entryController.getTmdbTopRated);
entryRouter.get("/tmdb/upcoming/movie", entryController.getTmdbUpcoming);
entryRouter.get("/tmdb/search", entryController.getTmdbSearch);
entryRouter.get("/tmdb/preview/:type/:tmdbId", entryController.getTmdbPreview);
entryRouter.get('/sync-series', entryController.syncSeries);
entryRouter.get("/sync-series", entryController.syncSeries);
entryRouter.get('/', entryController.getAllEntries);
entryRouter.get('/:id', entryController.getEntryById);
entryRouter.post('/', entryController.fetchAndSaveNewEntry);
entryRouter.put('/:id', entryController.updateEntry);
entryRouter.put('/:id/ratings', entryController.updateEntryRatings);
entryRouter.put('/:id/ids', entryController.updateEntryIds);
entryRouter.delete('/:id', entryController.deleteEntry);
entryRouter.get("/", entryController.getAllEntries);
entryRouter.get("/:id", entryController.getEntryById);
entryRouter.post("/", entryController.fetchAndSaveNewEntry);
entryRouter.put("/:id", entryController.updateEntry);
entryRouter.put("/:id/ratings", entryController.updateEntryRatings);
entryRouter.put("/:id/ids", entryController.updateEntryIds);
entryRouter.delete("/:id", entryController.deleteEntry);
entryRouter.get('/:id/seasons', entryController.getEntrySeasons);
entryRouter.get('/:id/credits', entryController.getEntryCredits);
entryRouter.put('/:id/refresh', entryController.refrechEntry);
entryRouter.put('/:id/fetch-collection', entryController.fetchEntryCollection);
entryRouter.get("/:id/seasons", entryController.getEntrySeasons);
entryRouter.get("/:id/credits", entryController.getEntryCredits);
entryRouter.put("/:id/refresh", entryController.refrechEntry);
entryRouter.put("/:id/fetch-collection", entryController.fetchEntryCollection);
// ! ENTRY MEDIA
// * POST - ADD NEW ENTRY MEDIA (poster/backdrop/logo)
const upload = entryPicturesUpload.fields([
{ name: 'poster', maxCount: 1 },
{ name: 'backdrop', maxCount: 1 },
{ name: 'logo', maxCount: 1 }
{ name: "poster", maxCount: 1 },
{ name: "backdrop", maxCount: 1 },
{ name: "logo", maxCount: 1 },
]);
entryRouter.post('/:id/media', upload, async (req, res) => {
entryRouter.post("/:id/media", upload, async (req, res) => {
const { id } = req.params;
if (!req.files) {
return res.status(400).json({ message: 'No files uploaded' });
return res.status(400).json({ message: "No files uploaded" });
}
const entry = await Entry.findByPk(id);
if (!entry) {
return res.status(404).json({ message: 'Entry not found' });
return res.status(404).json({ message: "Entry not found" });
}
// Function to handle media creation based on uploaded file type
const fileType = ['poster', 'backdrop', 'logo'].find(type => req.files[type]);
const fileType = ["poster", "backdrop", "logo"].find(
(type) => req.files[type],
);
if (!fileType) {
return res.status(400).json({ message: 'Invalid media type' });
return res.status(400).json({ message: "Invalid media type" });
}
const file = req.files[fileType][0];
const createdMedia = await Media.create({
mediaable: 'entry',
mediaable: "entry",
mediaableId: id,
type: fileType,
path: file.filename,
isLocal: true,
isSelected: false,
isCustom: true
isCustom: true,
});
// ? generating low resolution preview
mediaOptimizerService.doGeneratePreview('entries', fileType + 's', file.filename).then((result) => {
const stream = fs.createReadStream(filePath);
stream.pipe(res);
mediaOptimizerService
.doGeneratePreview("entries", fileType + "s", file.filename)
.then((result) => {
const stream = fs.createReadStream(filePath);
stream.pipe(res);
const msg = `Media Route | Generated Entry Preview`
logToFile(msg);
}).catch((err) => {
const msg = `Media Route | Error Generating Entry Preview`
logToFile(msg);
});
const msg = `Media Route | Generated Entry Preview`;
logToFile(msg);
})
.catch((err) => {
const msg = `Media Route | Error Generating Entry Preview`;
logToFile(msg);
});
return res.status(200).json(createdMedia);
});
// * PUT - SET ENTRY MEDIA AS SELECTED
entryRouter.put('/:entryId/media/:mediaId', upload, async (req, res) => {
entryRouter.put("/:entryId/media/:mediaId", upload, async (req, res) => {
const entryId = req.params.entryId;
const mediaId = req.params.mediaId;
const entry = await Entry.findByPk(entryId);
if (!entry) {
return res.status(404).json({ message: 'Entry not found' });
return res.status(404).json({ message: "Entry not found" });
}
const media = await Media.findByPk(mediaId);
if (!media) {
return res.status(404).json({ message: 'Media not found' });
return res.status(404).json({ message: "Media not found" });
}
// ? setting all other media to not selected
@@ -107,11 +111,11 @@ entryRouter.put('/:entryId/media/:mediaId', upload, async (req, res) => {
{ isSelected: false },
{
where: {
mediaable: 'entry',
mediaable: "entry",
mediaableId: entryId,
type: media.type
}
}
type: media.type,
},
},
);
const updatedMedia = await media.update({ isSelected: true });
@@ -119,7 +123,7 @@ entryRouter.put('/:entryId/media/:mediaId', upload, async (req, res) => {
});
// * DELETE - DELETE AND ENTRY MEDIA
entryRouter.delete('/:entryId/media/:mediaId', async (req, res) => {
entryRouter.delete("/:entryId/media/:mediaId", async (req, res) => {
const mediaId = req.params.mediaId;
// ? just before deleting we need to check if the deleted media was the one selected
@@ -128,11 +132,11 @@ entryRouter.delete('/:entryId/media/:mediaId', async (req, res) => {
if (media && media.isSelected) {
let otherMedia = await Media.findOne({
where: {
mediaable: 'entry',
mediaable: "entry",
mediaableId: media.mediaableId,
type: media.type,
isSelected: false
}
isSelected: false,
},
});
// ? if found select the first one
@@ -141,10 +145,9 @@ entryRouter.delete('/:entryId/media/:mediaId', async (req, res) => {
}
}
await Media.destroy({ where: { id: mediaId } })
await Media.destroy({ where: { id: mediaId } });
res.status(200).json();
});
module.exports = entryRouter;