hedgedoc/lib/web/middleware/tooBusy.ts
David Mehren e5961336b7
Add middleware/index.ts and remove default exports
Signed-off-by: David Mehren <dmehren1@gmail.com>
2020-04-25 16:04:13 +02:00

14 lines
372 B
TypeScript

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