diff --git a/lib/expressapp.js b/lib/expressapp.js index 142a23f..aafceda 100644 --- a/lib/expressapp.js +++ b/lib/expressapp.js @@ -439,8 +439,9 @@ ExpressApp.prototype.start = function(opts, cb) { router.get('/v1/notifications/', function(req, res) { getServerWithAuth(req, res, function(server) { + var timeSpan = req.query.timeSpan ? Math.min(+req.query.timeSpan || 0, 60) : 60; var opts = { - minTs: Math.max(+req.query.minTs || 0, +Date.now() - (60 * 1000)), + minTs: +Date.now() - (timeSpan * 1000), notificationId: req.query.notificationId, }; server.getNotifications(opts, function(err, notifications) { diff --git a/test/expressapp.js b/test/expressapp.js index faedbb9..7b73d2d 100644 --- a/test/expressapp.js +++ b/test/expressapp.js @@ -127,7 +127,7 @@ describe('ExpressApp', function() { it('should allow custom minTs within limits', function(done) { start(TestExpressApp, function() { var requestOptions = { - url: testHost + ':' + testPort + config.basePath + '/v1/notifications' + '?minTs=' + (Date.now() - 30000), + url: testHost + ':' + testPort + config.basePath + '/v1/notifications' + '?timeSpan=30', headers: { 'x-identity': 'identity', 'x-signature': 'signature' @@ -147,7 +147,7 @@ describe('ExpressApp', function() { it('should limit minTs to 60 seconds', function(done) { start(TestExpressApp, function() { var requestOptions = { - url: testHost + ':' + testPort + config.basePath + '/v1/notifications' + '?minTs=' + (Date.now() - 90000), + url: testHost + ':' + testPort + config.basePath + '/v1/notifications' + '?timeSpan=90', headers: { 'x-identity': 'identity', 'x-signature': 'signature'