Add hello-world express GET and POST endpoints - WIP

This commit is contained in:
Nikhil Nawgiri 2024-10-26 23:00:52 +02:00
parent 7eefe90d8c
commit 58c8682376

View file

@ -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();