From 3d31d039d83ddb24b0aeb5ccaf4cd2b7dec7c84b Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Tue, 8 Oct 2024 22:13:25 +0300 Subject: [PATCH] serve updated merged calendar to user --- merged_calendar_url.txt | 0 server.js | 8 +++++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 merged_calendar_url.txt diff --git a/merged_calendar_url.txt b/merged_calendar_url.txt new file mode 100644 index 0000000..e69de29 diff --git a/server.js b/server.js index 30ad579..c41a372 100644 --- a/server.js +++ b/server.js @@ -185,13 +185,19 @@ END:VEVENT } } - // Schedule a cron job to update the merged calendar every hour cron.schedule('0 * * * *', () => { console.log('Updating merged calendar...'); updateMergedCalendar(); }); +// serve updated merged calendar to user +app.get('/merged-calendar', (req, res) => { + const mergedCalendarUrlFile = 'merged_calendar_url.txt'; + const mergedCalendarUrl = fs.readFileSync(mergedCalendarUrlFile, 'utf8'); + res.redirect(mergedCalendarUrl); + }); + // Start the server const port = 3000; app.listen(port, () => {