1
0
Fork 0

update refresh calendar endpoint to have some error handling

This commit is contained in:
Ryan Mwangi 2024-10-22 14:32:28 +03:00
parent a3703ef485
commit 77f19504a2
1 changed files with 7 additions and 1 deletions

View File

@ -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