Add hello-world express GET and POST endpoints - WIP
This commit is contained in:
parent
7eefe90d8c
commit
58c8682376
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue