renamed backend routes files + add fields to entry model

This commit is contained in:
X4Lo committed 2024-05-18 15:37:02 +01:00
1 parent 21aaead02a
commit d6c3a974a1
13 files changed
+24 -18

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
const express = require('express');
const entryIdsRouter = express.Router();
// ! /entry-ids
// * PUT - UPDATE ENTRY RATING BY ID
entryIdsRouter.put('/:id', async (req, res) => {
try {
const { id } = req.params;
const { tmdb_id, imdb_id, tvdb_id } = req.body;
const entryId = await EntryId.findByPk(id);
if (!entryId) { // ! entry not found
return res.status(404).send('EntryId not found');
}
entryId.tmdb_id = tmdb_id ?? entryId.tmdb_id;
entryId.imdb_id = imdb_id ?? entryId.imdb_id;
entryId.tvdb_id = tvdb_id ?? entryId.tvdb_id;
await entryId.save();
res.status(200).json(entryId);
} catch (error) {
res.status(500).send('Server error');
}
});
module.exports = entryIdsRouter;