From bd3ab65003db0047460c70edf608e593bda8687d Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Thu, 24 Oct 2024 15:08:11 +0300 Subject: [PATCH] delete saveCalendarDatajoint function --- server.js | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/server.js b/server.js index dd7782a..8e73bcc 100644 --- a/server.js +++ b/server.js @@ -106,43 +106,13 @@ END:VEVENT } }); -// Serve the merged calendar file +// 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 saveCalendarDataJoint(calendarId, linkGroupName, calendars) { - let calendarsData = { mergedCalendars: [] }; - if (fs.existsSync(CALENDARS_FILE)) { - try { - const fileContent = fs.readFileSync(CALENDARS_FILE, 'utf8'); - if (fileContent) { - calendarsData = JSON.parse(fileContent); - } - } catch (error) { - console.error('Error reading calendars file:', error); - } - } - // Ensure mergedCalendars array exists - if (!calendarsData.mergedCalendars) { - calendarsData.mergedCalendars = []; - } - - calendarsData.mergedCalendars.push({ - id: calendarId, - linkGroupName: linkGroupName, - calendars: calendars - }); - - try { - fs.writeFileSync(CALENDARS_FILE, JSON.stringify(calendarsData, null, 2)); - } catch (error) { - console.error('Error writing to calendars file:', error); - } -} //function to save calendar data to seperate .json files function saveCalendarData(calendarId, linkGroupName, calendars) { const calendarFile = `${MERGED_CALENDARS_DIR}/${calendarId}.json`;