30 lines
984 B
TypeScript
Raw Normal View History

2023-04-18 02:57:36 +03:00
function startServer(port : number) {
console.log("Started startServer function")
const express = require("express");
const getThemeList = require("./getThemeList.js");
const getThemeDetails = require("./getThemeDetails.js");
const app = express();
const cors = require("cors");
app.use(cors());
var themeListReqCounter = 0;
2023-05-10 11:49:48 -06:00
app.get("/themes", (req : any, res : any) => {
2023-04-18 02:57:36 +03:00
themeListReqCounter++;
2023-05-10 11:49:48 -06:00
console.log("Got request on /themes, request number " + themeListReqCounter)
2023-04-18 02:57:36 +03:00
res.send(getThemeList());
});
var themeDetailsReqCounter = 0;
2023-05-10 11:49:48 -06:00
app.get("/theme/:id", (req : any, res : any) => {
2023-04-18 02:57:36 +03:00
themeDetailsReqCounter++;
2023-05-10 11:49:48 -06:00
console.log("Got request on /theme/" + req.params.id + ", request number " + themeDetailsReqCounter)
2023-04-18 02:57:36 +03:00
res.send(getThemeDetails(req.params.id));
});
app.listen(port, () => {
console.log(`Listening on port ${port}`);
});
}
module.exports = startServer;