codimd/lib/middleware/tooBusy.js

17 lines
308 B
JavaScript
Raw Permalink Normal View History

2017-04-11 22:05:43 +00:00
'use strict'
const toobusy = require('toobusy-js')
const config = require('../config')
const response = require('../response')
2017-04-11 22:05:43 +00:00
toobusy.maxLag(config.responseMaxLag)
2017-04-11 22:05:43 +00:00
module.exports = function (req, res, next) {
if (toobusy()) {
response.errorServiceUnavailable(req, res)
2017-04-11 22:05:43 +00:00
} else {
next()
}
}