From 7ef17fd4e61503178875dd34f998203264ffb691 Mon Sep 17 00:00:00 2001 From: BoHong Li Date: Wed, 12 Apr 2017 06:05:43 +0800 Subject: refactor(app.js): Extract tooBusy --- lib/web/middleware/tooBusy.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 lib/web/middleware/tooBusy.js (limited to 'lib/web/middleware/tooBusy.js') diff --git a/lib/web/middleware/tooBusy.js b/lib/web/middleware/tooBusy.js new file mode 100644 index 00000000..f1b72330 --- /dev/null +++ b/lib/web/middleware/tooBusy.js @@ -0,0 +1,13 @@ +'use strict' + +const toobusy = require('toobusy-js') + +const response = require('../../response') + +module.exports = function (req, res, next) { + if (toobusy()) { + response.errorServiceUnavailable(res) + } else { + next() + } +} -- cgit v1.2.3