30 lines
1004 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;
app.get("/themelist", (req : any, res : any) => {
themeListReqCounter++;
console.log("Got request on /themelist, request number " + themeListReqCounter)
res.send(getThemeList());
});
var themeDetailsReqCounter = 0;
app.get("/themedetails/:id", (req : any, res : any) => {
themeDetailsReqCounter++;
console.log("Got request on /themedetails/" + req.params.id + ", request number " + themeDetailsReqCounter)
res.send(getThemeDetails(req.params.id));
});
app.listen(port, () => {
console.log(`Listening on port ${port}`);
});
}
module.exports = startServer;