summaryrefslogtreecommitdiff
path: root/lib/web/middleware/tooBusy.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/web/middleware/tooBusy.js13
1 files changed, 13 insertions, 0 deletions
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()
+ }
+}