diff --git a/routes/api.js b/routes/api.js index 95c97f0..b0092d0 100644 --- a/routes/api.js +++ b/routes/api.js @@ -11,7 +11,7 @@ var uuid = require('node-uuid') module.exports = function(app) { // JSON API app.get('/api/stats/:id', statsShow); - app.get('/api/matches', matches); + app.get('/api/matches/:limit', matches); app.get('/api/player/:id', player); app.get('/api/player/:id/matches', playerMatches); app.get('/api/playersearch', playerSearch); @@ -74,9 +74,14 @@ var statsShow = function(req, res) { }; var matches = function(req, res) { + var limitCount = req.params.limit; + if (limitCount < 1 || limitCount == null) { + limitCount = 12; //Default Value if one is not specified + } + limitCount = Math.min(limitCount, 100); //Limits Count to a Maximum of 100 Stats.find({}) .sort({_id:-1}) - .limit(12) + .limit(limitCount) .select('hostname redname bluname redCountry bluCountry isLive') .lean() .exec(function(err, matches) {