mirror of
https://github.com/status-im/codimd.git
synced 2025-01-12 22:54:18 +00:00
ts: lib/middleware/tooBusy.js
Signed-off-by: Raccoon <raccoon@hackmd.io>
This commit is contained in:
parent
cf630ede21
commit
231672d455
@ -1,16 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
const toobusy = require('toobusy-js')
|
|
||||||
|
|
||||||
const config = require('../config')
|
|
||||||
const response = require('../response')
|
|
||||||
|
|
||||||
toobusy.maxLag(config.responseMaxLag)
|
|
||||||
|
|
||||||
module.exports = function (req, res, next) {
|
|
||||||
if (toobusy()) {
|
|
||||||
response.errorServiceUnavailable(req, res)
|
|
||||||
} else {
|
|
||||||
next()
|
|
||||||
}
|
|
||||||
}
|
|
14
lib/middleware/tooBusy.ts
Normal file
14
lib/middleware/tooBusy.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import * as toobusy from "toobusy-js";
|
||||||
|
|
||||||
|
import * as config from "../config";
|
||||||
|
import * as response from "../response";
|
||||||
|
|
||||||
|
toobusy.maxLag(config.responseMaxLag)
|
||||||
|
|
||||||
|
export = function (req, res, next) {
|
||||||
|
if (toobusy()) {
|
||||||
|
response.errorServiceUnavailable(req, res)
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user