summaryrefslogtreecommitdiff
path: root/lib/web/middleware/tooBusy.js
blob: 49efbe37339befb596ca80474d7f58190d246db3 (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 response = require('../../response')
const config = require('../../config')

toobusy.maxLag(config.tooBusyLag)

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