the web server returns a static files

This commit is contained in:
Kfir Dayan 2023-03-30 13:22:24 +03:00
parent 75c43c3443
commit d6d682a4b0
6 changed files with 11 additions and 105 deletions

1
.gitignore vendored
View file

@ -3,6 +3,7 @@ node_modules
#javascript build files # #javascript build files #
public public
dist
# Tmp files # # Tmp files #
tmp tmp

View file

@ -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

View file

@ -9,7 +9,7 @@
"node-html-parser": "^6.1.5" "node-html-parser": "^6.1.5"
}, },
"scripts": { "scripts": {
"dev": "nodemon public/index.js" "dev": "nodemon dist/index.js"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^18.15.5" "@types/node": "^18.15.5"

View file

@ -1,18 +1,14 @@
// Create a webserver with express // Create a webserver with express
// This is the main webserver for the application // This is the main webserver for the application
// It is responsible for serving the static files and the API // It is responsible for serving the static files and the API
import express from 'express' import express from 'express'
import fs from 'fs'
const app = express()
const port = 3000
app.get('/', (req, res) => { const app = express();
fs.readFile('../macabi-haifa-fc.ics', (err, data) => { app.use(express.static('public'))
res.header('Content-Type', 'text/calendar');
res.send(data);
})
})
app.listen(port, () => { app.listen(3000, () => {
console.log(`Example app listening on port ${port}`) console.log('Example app listening on port 3000!')
}) })

View file

@ -32,7 +32,7 @@ class App {
const app = new App(); const app = new App();
const start = async () => { const start = async () => {
const outputFileLocation = 'maccabi-haifa-fc.ics'; const outputFileLocation = 'public/maccabi-haifa-fc.ics';
const games = await app.gameSource.getGamesFromHaifa(); const games = await app.gameSource.getGamesFromHaifa();
const icsEvents = app.ics.generateIcsOutputFromGames(games); const icsEvents = app.ics.generateIcsOutputFromGames(games);
fs.writeFileSync(outputFileLocation, icsEvents); fs.writeFileSync(outputFileLocation, icsEvents);

View file

@ -5,7 +5,7 @@
"esModuleInterop": true, "esModuleInterop": true,
"target": "ES2019", "target": "ES2019",
"moduleResolution": "node", "moduleResolution": "node",
"outDir": "./public", "outDir": "./dist",
"rootDir": "./src" "rootDir": "./src"
} }
} }