mirror of
https://github.com/zoriya/flood.git
synced 2025-12-05 23:06:20 +00:00
15 lines
359 B
TypeScript
15 lines
359 B
TypeScript
import {RequestHandler} from 'express';
|
|
import expressRateLimit, {Options} from 'express-rate-limit';
|
|
|
|
import config from '../../config';
|
|
|
|
export function rateLimit(passedOptions?: Partial<Options>): RequestHandler {
|
|
if (config.disableRateLimit) {
|
|
return function (req, res, next) {
|
|
next();
|
|
};
|
|
}
|
|
|
|
return expressRateLimit(passedOptions);
|
|
}
|