Compare commits

...

7 commits

Author SHA1 Message Date
Kfir Dayan
4ff7cdb438 done with dockerizing 2023-04-02 16:42:09 +03:00
Kfir Dayan
49b42b83b9 done with dockerizing 2023-04-02 16:40:49 +03:00
Kfir Dayan
85e1f7b863 done with dockerizing 2023-04-02 16:22:49 +03:00
Kfir Dayan
71da8d04ee wip 2023-04-02 16:09:45 +03:00
Kfir Dayan
70aa6c0dd2 fixing saving to public folder 2023-04-02 15:40:12 +03:00
Kfir Dayan
9442a17150 Merge branch 'master' into dockerizing_project 2023-04-02 15:36:35 +03:00
Kfir Dayan
1a9742f921 Dockerfile created 2023-04-02 10:14:38 +03:00
5 changed files with 40 additions and 90 deletions

4
.dockerignore Normal file
View file

@ -0,0 +1,4 @@
node_modules
npm-debug.log
src
tmp

19
Dockerfile Normal file
View file

@ -0,0 +1,19 @@
FROM node:16
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm install
# If you are building your code for production
# RUN npm ci --omit=dev
# Bundle app source
COPY . .
EXPOSE ${PORT}
CMD [ "node", "dist/index.js" ]

View file

@ -1,77 +0,0 @@
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:https://mhaifafc.com/
METHOD:PUBLISH
X-PUBLISHED-TTL:PT1H
BEGIN:VEVENT
UID:_5qS0t0NPnxt7ysQhiM1b
SUMMARY:Maccabi Haifa F.C.
DTSTAMP:20230402T122458Z
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:gOdljSPvOnSsLTwF_JSdA
SUMMARY:Maccabi Haifa F.C.
DTSTAMP:20230402T122458Z
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:6VKjleqclIMSj6TG7bx4_
SUMMARY:Maccabi Haifa F.C.
DTSTAMP:20230402T122458Z
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:yabS2xjYG6txukIHZCeFV
SUMMARY:Maccabi Haifa F.C.
DTSTAMP:20230402T122458Z
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:cuLZKgXMny8Utk3LInSVj
SUMMARY:Maccabi Haifa F.C.
DTSTAMP:20230402T122458Z
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

@ -10,7 +10,9 @@
"node-html-parser": "^6.1.5" "node-html-parser": "^6.1.5"
}, },
"scripts": { "scripts": {
"dev": "nodemon dist/index.js" "dev": "nodemon dist/index.js",
"build": "tsc",
"start": "node dist/index.js"
}, },
"devDependencies": { "devDependencies": {
"@types/express": "^4.17.17", "@types/express": "^4.17.17",

View file

@ -3,6 +3,10 @@ import GameSource from './GameSource';
import fs from 'fs'; import fs from 'fs';
import Ics from './Ics'; import Ics from './Ics';
import express from 'express' import express from 'express'
import env from 'dotenv';
env.config();
const CronJob = require('cron').CronJob; const CronJob = require('cron').CronJob;
@ -34,31 +38,29 @@ class App {
} }
const app = new App(); const app = new App();
console.log("Declaring Cron Job every day at 10:00")
console.log("Declaring Cron Job")
const cron = "0 10 * * *" // every day at 10:00
const job = new CronJob( const job = new CronJob(
"* * * * *", "0 10 * * *", // every day at 10:00,
async () => { async () => {
console.log("START") console.log("Staring a new job")
const outputFileLocation = 'maccabi-haifa-fc.ics'; const outputFileLocation = 'public/maccabi-haifa-fc.ics';
console.log("Getting games from Haifa")
const games = await app.gameSource.getGamesFromHaifa(); const games = await app.gameSource.getGamesFromHaifa();
console.log("Generating ICS file")
const icsEvents = app.ics.generateIcsOutputFromGames(games); const icsEvents = app.ics.generateIcsOutputFromGames(games);
console.log("Writing ICS file to " + outputFileLocation)
fs.writeFileSync(outputFileLocation, icsEvents); fs.writeFileSync(outputFileLocation, icsEvents);
console.log("Done")
}, },
null, null,
true, true,
'Asia/Jerusalem' 'Asia/Jerusalem'
); );
const webServer = express(); const webServer = express();
webServer.use(express.static('public')) webServer.use(express.static('public'))
webServer.listen(3000, () => { webServer.listen(process.env.PORT, () => {
console.log('Example app listening on port 3000!') console.log('Example app listening on port '+process.env.PORT+'!')
}) })