From 89bd4582d1d9ea258fd419cb06a9123ad4ee37fd Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Wed, 2 Oct 2024 02:06:52 +0300 Subject: [PATCH] validate the different calender inputs --- server.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index b840e2e..6ec690d 100644 --- a/server.js +++ b/server.js @@ -14,9 +14,13 @@ app.get('/', (req, res) => { }); app.post('/merge', async (req, res) => { - const { cal1Url, cal1Prefix, cal2Url, cal2Prefix } = req.body; + const { calendars } = req.body; try { + //validate the input + if (!calendars || !Array.isArray(calendars)) { + return res.status(400).json({ error: 'Invalid input' }); + } // Fetch calendar data from URLs const cal1Data = await axios.get(cal1Url); const cal2Data = await axios.get(cal2Url);