Compare commits

..

3 commits

Author SHA1 Message Date
Kfir Dayan
5e0e203fa3 adding cron 2023-04-02 11:13:43 +03:00
Kfir Dayan
831dfaaea0 every day at 10am the script runs 2023-04-02 11:10:44 +03:00
Kfir Dayan
4360499dd0 git ignoring dist 2023-04-02 10:15:25 +03:00
4 changed files with 19 additions and 1289 deletions

1
.gitignore vendored
View file

@ -14,3 +14,4 @@ tmp
config/client_google_auth.json
## output ##
dist

1282
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,7 @@
{
"dependencies": {
"axios": "^1.3.4",
"cron": "^2.3.0",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"googleapis": "^113.0.0",

View file

@ -3,6 +3,8 @@ import GameSource from './GameSource';
import fs from 'fs';
import Ics from './Ics';
const CronJob = require('cron').CronJob;
class App {
googleCalendar: GoogleCalendar;
@ -31,11 +33,19 @@ class App {
const app = new App();
const start = async () => {
const outputFileLocation = 'public/maccabi-haifa-fc.ics';
const games = await app.gameSource.getGamesFromHaifa();
const icsEvents = app.ics.generateIcsOutputFromGames(games);
fs.writeFileSync(outputFileLocation, icsEvents);
}
start();
const job = new CronJob(
"0 10 * * *",
async () => {
console.log("START")
const outputFileLocation = 'maccabi-haifa-fc.ics';
const games = await app.gameSource.getGamesFromHaifa();
const icsEvents = app.ics.generateIcsOutputFromGames(games);
fs.writeFileSync(outputFileLocation, icsEvents);
},
null,
true,
'Asia/Jerusalem'
);