1
0
Fork 0

store merged calendar url in a file

This commit is contained in:
Ryan Mwangi 2024-10-08 22:04:31 +03:00
parent 1552cc2013
commit e01c54e267
1 changed files with 6 additions and 1 deletions

View File

@ -109,7 +109,7 @@ async function updateMergedCalendar(){
// Load calendars data from file // Load calendars data from file
const calendarsFile = 'calendars.json'; const calendarsFile = 'calendars.json';
const calendars = JSON.parse(fs.readFileSync(calendarsFile, 'utf8')); const calendars = JSON.parse(fs.readFileSync(calendarsFile, 'utf8'));
// Fetch calendar data from URLs // Fetch calendar data from URLs
const promises = calendars.map((calendar) => { const promises = calendars.map((calendar) => {
return axios.get(calendar.url) return axios.get(calendar.url)
@ -168,10 +168,15 @@ END:VEVENT
`; `;
}); });
icalString += `END:VCALENDAR`; icalString += `END:VCALENDAR`;
fs.writeFileSync(filename, icalString); fs.writeFileSync(filename, icalString);
// Generate a unique URL for the merged calendar // Generate a unique URL for the merged calendar
const mergedCalendarUrl = `${req.protocol}://${req.get('host')}/${filename}`; 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}`); console.log(`Merged calendar updated: ${mergedCalendarUrl}`);