ts: lib/middleware/tooBusy.js

Signed-off-by: Raccoon <raccoon@hackmd.io>
This commit is contained in:
Raccoon 2021-06-12 05:20:27 +08:00
parent cf630ede21
commit 231672d455
No known key found for this signature in database
GPG Key ID: 06770355DC9ECD38
2 changed files with 14 additions and 16 deletions

View File

@ -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
View 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()
}
}