adding cron
This commit is contained in:
commit
5e0e203fa3
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
|
config/client_google_auth.json
|
||||||
|
|
||||||
## output ##
|
## 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": {
|
"dependencies": {
|
||||||
"axios": "^1.3.4",
|
"axios": "^1.3.4",
|
||||||
|
"cron": "^2.3.0",
|
||||||
"dotenv": "^16.0.3",
|
"dotenv": "^16.0.3",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"googleapis": "^113.0.0",
|
"googleapis": "^113.0.0",
|
||||||
|
|
18
src/index.ts
18
src/index.ts
|
@ -3,6 +3,8 @@ import GameSource from './GameSource';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import Ics from './Ics';
|
import Ics from './Ics';
|
||||||
|
|
||||||
|
const CronJob = require('cron').CronJob;
|
||||||
|
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
googleCalendar: GoogleCalendar;
|
googleCalendar: GoogleCalendar;
|
||||||
|
@ -31,11 +33,19 @@ class App {
|
||||||
|
|
||||||
const app = new App();
|
const app = new App();
|
||||||
|
|
||||||
const start = async () => {
|
|
||||||
const outputFileLocation = 'public/maccabi-haifa-fc.ics';
|
const job = new CronJob(
|
||||||
|
"0 10 * * *",
|
||||||
|
async () => {
|
||||||
|
console.log("START")
|
||||||
|
const outputFileLocation = '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);
|
||||||
}
|
},
|
||||||
|
null,
|
||||||
|
true,
|
||||||
|
'Asia/Jerusalem'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
start();
|
|
Loading…
Reference in a new issue