haifa-reminder/src/index.ts
2023-03-21 19:17:36 +02:00

36 lines
855 B
TypeScript

import GameSource from "./GameSource";
import GoogleCalendar from './GoogleCalendar'
const gameSource = new GameSource();
const googleCalendar = new GoogleCalendar();
if(googleCalendar.connected) {
console.log("Successfully Connected To Google API");
} else {
console.log("Failed To Connect To Google API");
}
// create an app that scan the output gameSource and add events to google calendar
export default class App {
constructor() {
this.run();
}
async run() {
const games = await gameSource.getGames();
this.dropOutputToTmpFIle(games);
}
dropOutputToTmpFIle(games: any) {
const fs = require('fs');
fs.writeFile("tmp/output.json", JSON.stringify(games), function(err: any) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});
}
}
const app = new App();