@mark01/express-utils
Version:
npm package that contains utilities for express.js
13 lines (12 loc) • 348 B
JavaScript
import toobusy from 'toobusy-js';
import { AppError } from '../error';
export const busyHandler = () => (_, __, next) => {
toobusy.maxLag(200);
toobusy.interval(750);
if (toobusy()) {
next(new AppError('API is currently too busy. Please try again later!', 503));
return;
}
next();
};
export default busyHandler;