From 77f19504a2a19112ee02851dcc3e6cc2961aa378 Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Tue, 22 Oct 2024 14:32:28 +0300 Subject: [PATCH] update refresh calendar endpoint to have some error handling --- server.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 309b680..351bf35 100644 --- a/server.js +++ b/server.js @@ -229,7 +229,13 @@ END:VEVENT // Endpoint to refresh the merged calendar app.post('/refresh/:id', async (req, res) => { const calendarId = req.params.id; - await updateMergedCalendars(calendarId); + try { + await updateMergedCalendars(calendarId); + res.json({ message: `Merged calendar refreshed: ${calendarId}` }); + } catch (error) { + console.error(error); + res.status(500).json({ error: `Failed to refresh merged calendar: ${calendarId}` }); + } }); // Schedule a cron job to update the merged calendar every hour