From 856768103ea8317e5c4cf90e4c6d6999fafdd0a2 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 1 Dec 2016 12:42:35 -0300 Subject: [PATCH] fix rate limitation only for POST --- lib/expressapp.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/expressapp.js b/lib/expressapp.js index 2896b1c..bfc402b 100644 --- a/lib/expressapp.js +++ b/lib/expressapp.js @@ -171,16 +171,21 @@ ExpressApp.prototype.start = function(opts, cb) { }; + var createWalletLimiter; if (Defaults.RateLimit.createWallet) { log.info('', 'Limiting wallet creation per IP: %d req/h', (Defaults.RateLimit.createWallet.max / Defaults.RateLimit.createWallet.windowMs * 60 * 60 * 1000).toFixed(2)) - var createWalletLimiter = new RateLimit(Defaults.RateLimit.createWallet); - router.use(/\/v\d+\/wallets\/$/, createWalletLimiter) + createWalletLimiter = new RateLimit(Defaults.RateLimit.createWallet); + // router.use(/\/v\d+\/wallets\/$/, createWalletLimiter) + } else { + createWalletLimiter = function(req, res, next) { + next() + }; } // DEPRECATED - router.post('/v1/wallets/', function(req, res) { + router.post('/v1/wallets/', createWalletLimiter, function(req, res) { logDeprecated(req); var server; try { @@ -197,7 +202,7 @@ ExpressApp.prototype.start = function(opts, cb) { }); }); - router.post('/v2/wallets/', function(req, res) { + router.post('/v2/wallets/', createWalletLimiter, function(req, res) { var server; try { server = getServer(req, res);