diff --git a/be/src/main.ts b/be/src/main.ts index 1692db3..39c76a5 100644 --- a/be/src/main.ts +++ b/be/src/main.ts @@ -16,6 +16,9 @@ const run = async () => { }: JellyfinApiResponse = await fetchFromJellyfinApi(); const transformedItems = transformItems(items); + console.log("transformedItems:", transformedItems); + const arrayOfExistingImdbIds = transformedItems.map(item => item.imdbId); + console.log("arrayOfExistingImdbIds:", arrayOfExistingImdbIds); // saveJsonToDisk({ totalItemCount, jellyfinItems: transformedItems }); @@ -23,11 +26,18 @@ const run = async () => { res.json(transformedItems) }); - app.post("/bob", (req, res) => { - const { imdbId } = req.body; - console.log("imdbId:", imdbId); + // to do: endpoint to check single items against arrayOfExistingImdbIds - res.send("OK\n"); + app.post("/bob", (req, res) => { + const { imdbId: requestedImdbId } = req.body; + + if (arrayOfExistingImdbIds.includes(requestedImdbId)) { + res.send("DUP\n"); + } else { + // to do: push to wishlist array + // to do: save wishlist array to disk + res.send("OK\n"); + } }) app.listen(1312);