Compare commits
3 commits
bbb36d7cb6
...
58c8682376
Author | SHA1 | Date | |
---|---|---|---|
58c8682376 | |||
7eefe90d8c | |||
edfd5abd48 |
11
be/src/expressHelper.ts
Normal file
11
be/src/expressHelper.ts
Normal 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 };
|
|
@ -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();
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
"moduleResolution": "node",
|
||||
"experimentalDecorators": true,
|
||||
"noImplicitAny": true,
|
||||
"allowImportingTsExtensions": true
|
||||
"allowImportingTsExtensions": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue