Compare commits

..

No commits in common. "37108217d8f234ae9462cf8b0a5dd95042293938" and "1552cc20137a868cb6a09e9564f84dcbc4f44f4d" have entirely different histories.

2 changed files with 3 additions and 14 deletions

View file

@ -168,15 +168,10 @@ 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 = `http://localhost:3000/${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}`);
@ -185,19 +180,13 @@ END:VEVENT
} }
} }
// Schedule a cron job to update the merged calendar every hour // Schedule a cron job to update the merged calendar every hour
cron.schedule('0 * * * *', () => { cron.schedule('0 * * * *', () => {
console.log('Updating merged calendar...'); console.log('Updating merged calendar...');
updateMergedCalendar(); 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 // Start the server
const port = 3000; const port = 3000;
app.listen(port, () => { app.listen(port, () => {