UNPKG

express-toobusy

Version:

Express middleware to return 503 if server is too busy right now

18 lines (13 loc) 331 B
var toobusy = require('toobusy-js'); module.exports = function(maxLag) { if (maxLag) { toobusy.maxLag(maxLag); } return function expressToobusy(req, res, next) { if (toobusy()) { res.status(503).send("Server is too busy. Please, try again later."); } else { next(); } } };