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

@ -97,7 +97,7 @@ END:VEVENT
// Save the user input and generated ID in calendars.json file
saveCalendarData(calendarId, calendars);
// Save the user input in a calendars.json file
const calendarsFile = 'calendars.json';
let calendarsData = {};
@ -129,6 +129,14 @@ END:VEVENT
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 saveCalendarData(calendarId, calendars) {
let calendarsData = { mergedCalendars: [] };