diff --git a/.gitignore b/.gitignore index b05ac72..5c01129 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ node_modules #javascript build files # public +dist # Tmp files # tmp diff --git a/maccabi-haifa-fc.ics b/maccabi-haifa-fc.ics deleted file mode 100644 index 4f476d0..0000000 --- a/maccabi-haifa-fc.ics +++ /dev/null @@ -1,91 +0,0 @@ -BEGIN:VCALENDAR -VERSION:2.0 -CALSCALE:GREGORIAN -PRODID:https://mhaifafc.com/ -METHOD:PUBLISH -X-PUBLISHED-TTL:PT1H -BEGIN:VEVENT -UID:wLJtzrqtQbYPsIZvCMLMo -SUMMARY:Maccabi Haifa F.C. -DTSTAMP:20230330T062349Z -DTSTART:20230401T170000Z -DTEND:20230401T190000Z -DESCRIPTION:Maccabi Haifa vs. H Be'er Sheva -URL:https://mhaifafc.com/ -LOCATION:Sammy Ofer Stadium -STATUS:CONFIRMED -CATEGORIES: -ORGANIZER;CN=Maccabi Haifa F.C. -X-MICROSOFT-CDO-BUSYSTATUS:BUSY -END:VEVENT -BEGIN:VEVENT -UID:hISCIUyjm8DDAMwb2OnVZ -SUMMARY:Maccabi Haifa F.C. -DTSTAMP:20230330T062349Z -DTSTART:20230404T173000Z -DTEND:20230404T193000Z -DESCRIPTION:Maccabi Tel aviv vs. Maccabi Haifa -URL:https://mhaifafc.com/ -LOCATION:Sammy Ofer Stadium -STATUS:CONFIRMED -CATEGORIES: -ORGANIZER;CN=Maccabi Haifa F.C. -X-MICROSOFT-CDO-BUSYSTATUS:BUSY -END:VEVENT -BEGIN:VEVENT -UID:uW_fM4iOaN39jICgwGj6X -SUMMARY:Maccabi Haifa F.C. -DTSTAMP:20230330T062349Z -DTSTART:20230408T170000Z -DTEND:20230408T190000Z -DESCRIPTION:Maccabi Haifa vs. Maccabi Netanya -URL:https://mhaifafc.com/ -LOCATION:Sammy Ofer Stadium -STATUS:CONFIRMED -CATEGORIES: -ORGANIZER;CN=Maccabi Haifa F.C. -X-MICROSOFT-CDO-BUSYSTATUS:BUSY -END:VEVENT -BEGIN:VEVENT -UID:y_LKQN5CrNcUN3Zsvtu-5 -SUMMARY:Maccabi Haifa F.C. -DTSTAMP:20230330T062349Z -DTSTART:20230415T153000Z -DTEND:20230415T173000Z -DESCRIPTION:Hapoel Jerusalem vs. Maccabi Haifa -URL:https://mhaifafc.com/ -LOCATION:Sammy Ofer Stadium -STATUS:CONFIRMED -CATEGORIES: -ORGANIZER;CN=Maccabi Haifa F.C. -X-MICROSOFT-CDO-BUSYSTATUS:BUSY -END:VEVENT -BEGIN:VEVENT -UID:CKIjKn9UBqzm-x6LOLVjH -SUMMARY:Maccabi Haifa F.C. -DTSTAMP:20230330T062349Z -DTSTART:20230423T173000Z -DTEND:20230423T193000Z -DESCRIPTION:F.C Ashdod vs. Maccabi Haifa -URL:https://mhaifafc.com/ -LOCATION:Sammy Ofer Stadium -STATUS:CONFIRMED -CATEGORIES: -ORGANIZER;CN=Maccabi Haifa F.C. -X-MICROSOFT-CDO-BUSYSTATUS:BUSY -END:VEVENT -BEGIN:VEVENT -UID:wqUEwyIF9IMpXHqgxWX2V -SUMMARY:Maccabi Haifa F.C. -DTSTAMP:20230330T062349Z -DTSTART:20230501T173000Z -DTEND:20230501T193000Z -DESCRIPTION:H Be'er Sheva vs. Maccabi Haifa -URL:https://mhaifafc.com/ -LOCATION:Sammy Ofer Stadium -STATUS:CONFIRMED -CATEGORIES: -ORGANIZER;CN=Maccabi Haifa F.C. -X-MICROSOFT-CDO-BUSYSTATUS:BUSY -END:VEVENT -END:VCALENDAR diff --git a/package.json b/package.json index 7d6ba1c..0c159c7 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "node-html-parser": "^6.1.5" }, "scripts": { - "dev": "nodemon public/index.js" + "dev": "nodemon dist/index.js" }, "devDependencies": { "@types/node": "^18.15.5" diff --git a/src/WebServer.ts b/src/WebServer.ts index 10d6d9a..ccf1f53 100644 --- a/src/WebServer.ts +++ b/src/WebServer.ts @@ -1,18 +1,14 @@ // Create a webserver with express // This is the main webserver for the application // It is responsible for serving the static files and the API + + + import express from 'express' -import fs from 'fs' -const app = express() -const port = 3000 -app.get('/', (req, res) => { - fs.readFile('../macabi-haifa-fc.ics', (err, data) => { - res.header('Content-Type', 'text/calendar'); - res.send(data); - }) -}) +const app = express(); +app.use(express.static('public')) -app.listen(port, () => { - console.log(`Example app listening on port ${port}`) +app.listen(3000, () => { + console.log('Example app listening on port 3000!') }) \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 6651904..07292ce 100644 --- a/src/index.ts +++ b/src/index.ts @@ -32,7 +32,7 @@ class App { const app = new App(); const start = async () => { - const outputFileLocation = 'maccabi-haifa-fc.ics'; + const outputFileLocation = 'public/maccabi-haifa-fc.ics'; const games = await app.gameSource.getGamesFromHaifa(); const icsEvents = app.ics.generateIcsOutputFromGames(games); fs.writeFileSync(outputFileLocation, icsEvents); diff --git a/tsconfig.json b/tsconfig.json index 0c778a3..9326bb1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,7 @@ "esModuleInterop": true, "target": "ES2019", "moduleResolution": "node", - "outDir": "./public", + "outDir": "./dist", "rootDir": "./src" } } \ No newline at end of file