serve the merged calendar file

This commit is contained in:
Ryan Mwangi 2024-10-18 16:43:13 +03:00
parent 4b27d84f92
commit ecd4b3835c

View file

@ -129,6 +129,14 @@ END:VEVENT
res.status(500).json({ error: 'Failed to merge calendars' }); res.status(500).json({ error: 'Failed to merge calendars' });
} }
}); });
// Serve the merged calendar file
app.get('/calendar/:id', (req, res) => {
const filename = `${req.params.id}.ics`;
res.setHeader('Content-Type', 'text/calendar');
res.sendFile(filename, { root: MERGED_CALENDARS_DIR });
});
//function to save CalendarData to calendars.json //function to save CalendarData to calendars.json
function saveCalendarData(calendarId, calendars) { function saveCalendarData(calendarId, calendars) {
let calendarsData = { mergedCalendars: [] }; let calendarsData = { mergedCalendars: [] };