Compare commits

..

3 commits

Author SHA1 Message Date
Nikhil Nawgiri 58c8682376 Add hello-world express GET and POST endpoints - WIP 2024-10-26 23:00:52 +02:00
Nikhil Nawgiri 7eefe90d8c Add expressHelper 2024-10-26 22:48:33 +02:00
Nikhil Nawgiri edfd5abd48 Update tsconfig 2024-10-26 22:48:09 +02:00
3 changed files with 29 additions and 6 deletions

11
be/src/expressHelper.ts Normal file
View file

@ -0,0 +1,11 @@
import express, { type Express } from "express";
import bodyParser from "body-parser";
const app: Express = express();
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
export { app };

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

View file

@ -10,7 +10,8 @@
"moduleResolution": "node",
"experimentalDecorators": true,
"noImplicitAny": true,
"allowImportingTsExtensions": true
"allowImportingTsExtensions": true,
"allowSyntheticDefaultImports": true
},
"exclude": ["node_modules"]
}