hedgedoc/lib/web/middleware/tooBusy.ts

15 lines
380 B
TypeScript
Raw Normal View History

import toobusy from 'toobusy-js'
import { errors } from '../../errors'
import { config } from '../../config'
import { NextFunction, Request, Response } from 'express'
toobusy.maxLag(config.tooBusyLag)
export default function tooBusy (req: Request, res: Response, next: NextFunction): void {
if (toobusy()) {
errors.errorServiceUnavailable(res)
} else {
next()
}
}