Match controller now returns user recents if authenticated.

This commit is contained in:
Harrison Deng 2022-04-05 00:21:34 -05:00
parent 0f480af1f0
commit dd6dc787e9

View File

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