refactor middlewares in their own folder, move buildFiles to libs/buildFiles

This commit is contained in:
Matteo Pagliazzi
2015-08-14 11:50:09 +02:00
parent 078ea4768a
commit 47f6f2febe
16 changed files with 275 additions and 270 deletions

View File

@@ -0,0 +1,21 @@
var nconf = require('nconf');
var IS_PROD = nconf.get('NODE_ENV') === 'production';
module.exports = function(app) {
if (!IS_PROD) return;
app.use(limiter({
end:false,
catagories:{
normal: {
// 2 req/s, but split as minutes
totalRequests: 80,
every: 60000
}
}
})).use(function(req,res,next){
//logging.info(res.ratelimit);
if (res.ratelimit.exceeded) return res.json(429,{err:'Rate limit exceeded'});
next();
});
}