From 00f5fedb2ad7a82f82b98990956fb24ab036aa3c Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Thu, 7 Nov 2024 14:25:02 +0300 Subject: [PATCH] refactor: encapsulate calendar file saving with saveCalendarFile helper --- server.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server.js b/server.js index 88ed731..3bc8dd1 100644 --- a/server.js +++ b/server.js @@ -62,6 +62,13 @@ const mergeCalendarEvents = (calendarInstance, results) => { }); }; +// Save calendar data to file +const saveCalendarFile = (filename, content) => { + const filePath = path.join(MERGED_CALENDARS_DIR, filename); + fs.writeFileSync(filePath, content); + return filePath; +}; + // Merge calendars endpoint app.post('/merge', async (req, res) => { const { linkGroupName, calendars } = req.body;