Compare commits
7 commits
master
...
dockerizin
Author | SHA1 | Date | |
---|---|---|---|
|
4ff7cdb438 | ||
|
49b42b83b9 | ||
|
85e1f7b863 | ||
|
71da8d04ee | ||
|
70aa6c0dd2 | ||
|
9442a17150 | ||
|
1a9742f921 |
5 changed files with 40 additions and 90 deletions
4
.dockerignore
Normal file
4
.dockerignore
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
node_modules
|
||||||
|
npm-debug.log
|
||||||
|
src
|
||||||
|
tmp
|
19
Dockerfile
Normal file
19
Dockerfile
Normal 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" ]
|
|
@ -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
|
|
|
@ -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",
|
||||||
|
|
26
src/index.ts
26
src/index.ts
|
@ -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+'!')
|
||||||
})
|
})
|
Loading…
Reference in a new issue