From e01c54e267641eb1ebba884269ff6ff2c4725c37 Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Tue, 8 Oct 2024 22:04:31 +0300 Subject: [PATCH] store merged calendar url in a file --- server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index c155578..30ad579 100644 --- a/server.js +++ b/server.js @@ -109,7 +109,7 @@ async function updateMergedCalendar(){ // Load calendars data from file const calendarsFile = 'calendars.json'; const calendars = JSON.parse(fs.readFileSync(calendarsFile, 'utf8')); - + // Fetch calendar data from URLs const promises = calendars.map((calendar) => { return axios.get(calendar.url) @@ -168,10 +168,15 @@ END:VEVENT `; }); icalString += `END:VCALENDAR`; + fs.writeFileSync(filename, icalString); // Generate a unique URL for the merged calendar const mergedCalendarUrl = `${req.protocol}://${req.get('host')}/${filename}`; + + // Store the merged calendar URL in a file + fs.writeFileSync(mergedCalendarUrlFile, mergedCalendarUrl); + console.log(`Merged calendar updated: ${mergedCalendarUrl}`);