From 58c8682376eaf341d2e9740fc5ecbb42a7964860 Mon Sep 17 00:00:00 2001 From: Nikhil Nawgiri Date: Sat, 26 Oct 2024 23:00:52 +0200 Subject: [PATCH] Add hello-world express GET and POST endpoints - WIP --- be/src/main.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/be/src/main.ts b/be/src/main.ts index 5d45b54..1692db3 100644 --- a/be/src/main.ts +++ b/be/src/main.ts @@ -1,6 +1,7 @@ import { fetchFromJellyfinApi } from "./jellyfinApiHelper.ts"; import { saveJsonToDisk } from "./fsHelper.ts"; import { transformItems } from "./itemHelper.ts"; +import { app } from "./expressHelper.ts"; interface JellyfinApiResponse { Items?: [], @@ -15,13 +16,23 @@ const run = async () => { }: JellyfinApiResponse = await fetchFromJellyfinApi(); const transformedItems = transformItems(items); - saveJsonToDisk({ totalItemCount, jellyfinItems: transformedItems }); - // save as something else than json lol + // saveJsonToDisk({ totalItemCount, jellyfinItems: transformedItems }); - // express API - // GET endpoint - // POST endpoint + app.get("/dingle", (req, res) => { + res.json(transformedItems) + }); + + app.post("/bob", (req, res) => { + const { imdbId } = req.body; + console.log("imdbId:", imdbId); + + res.send("OK\n"); + }) + + app.listen(1312); + + // Add logic to endpoints } run();