diff --git a/sports-matcher/server/controllers/matchController.js b/sports-matcher/server/controllers/matchController.js index 8619e20..55b8fe2 100644 --- a/sports-matcher/server/controllers/matchController.js +++ b/sports-matcher/server/controllers/matchController.js @@ -26,8 +26,16 @@ MatchController.get("/search/:sport", needDatabase, async (req, res) => { }); MatchController.get("/recent/:limit?", needDatabase, async (req, res) => { + const user = req.user; let limit = req.params.limit; + if (limit && typeof (limit) !== "number") { + res.status(400).send("Limit parameter is not a number."); + } if (!req.params.limit) limit = 10; + if (user) { + res.status(200).send(user.participatingMatches.slice(limit)); + return; + } if (isNaN(limit)) { res.status(400).send("Limit parameter not a number."); return;