Match controller now returns user recents if authenticated.
This commit is contained in:
parent
0f480af1f0
commit
dd6dc787e9
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user