1
0
Fork 0

update /merge endpoint to use linkGroupName input

This commit is contained in:
Ryan Mwangi 2024-10-21 02:25:40 +03:00
parent e5202791ac
commit 3204bb8a4b
1 changed files with 4 additions and 4 deletions

View File

@ -26,11 +26,11 @@ app.get('/', (req, res) => {
});
app.post('/merge', async (req, res) => {
const { calendars } = req.body;
const { linkGroupName, calendars } = req.body;
try {
//validate the input
if (!calendars || !Array.isArray(calendars)) {
// Validate the input
if (!linkGroupName || !calendars || !Array.isArray(calendars)) {
return res.status(400).json({ error: 'Invalid input' });
}
// Generate a unique identifier for this set of calendars
@ -97,7 +97,7 @@ END:VEVENT
fs.writeFileSync(`${MERGED_CALENDARS_DIR}/${filename}`, icalString);
// Save the user input and generated ID in calendars.json file
saveCalendarData(calendarId, calendars);
saveCalendarData(calendarId, linkGroupName, calendars);
res.json({ url: `${req.protocol}://${req.get('host')}/calendar/${calendarId}` });
} catch (error) {