summaryrefslogtreecommitdiff
path: root/lib/web/middleware/tooBusy.js
blob: a2101975aeb2020070d869d55e9deae809eab464 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'use strict'

const toobusy = require('toobusy-js')

const errors = require('../../errors')
const config = require('../../config')

toobusy.maxLag(config.tooBusyLag)

module.exports = function (req, res, next) {
  if (toobusy()) {
    errors.errorServiceUnavailable(res)
  } else {
    next()
  }
}