@daiso-tech/core
Version:
The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.
21 lines • 726 B
JavaScript
/**
* @module RateLimiter
*/
import {} from "../../../middleware/contracts/_module.js";
import {} from "../../../rate-limiter/contracts/_module.js";
import { callInvokable, } from "../../../utilities/_module.js";
/**
* IMPORT_PATH: `"@daiso-tech/core/rate-limiter/middlewares"`
* @group Middleware
*/
export function rateLimiterMiddlewareFactory(rateLimiterFactory) {
return (settings) => {
const { key = (...args) => JSON.stringify(args), ...rest } = settings;
return ({ next, args }) => {
return rateLimiterFactory
.create(callInvokable(key, ...args), rest)
.runOrFail(next);
};
};
}
//# sourceMappingURL=rate-limiter-middleware-factory.js.map