Compare commits
3 commits
d6d682a4b0
...
5e0e203fa3
Author | SHA1 | Date | |
---|---|---|---|
|
5e0e203fa3 | ||
|
831dfaaea0 | ||
|
4360499dd0 |
4 changed files with 19 additions and 1289 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -14,3 +14,4 @@ tmp
|
|||
config/client_google_auth.json
|
||||
|
||||
## output ##
|
||||
dist
|
||||
|
|
1282
package-lock.json
generated
1282
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -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",
|
||||
|
|
24
src/index.ts
24
src/index.ts
|
@ -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'
|
||||
);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue