UNPKG

@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.

22 lines 802 B
/** * @module RateLimiter */ import {} from "../../../circuit-breaker/contracts/_module.js"; import {} from "../../../middleware/contracts/_module.js"; import {} from "../../../time-span/contracts/_module.js"; import { callInvokable, } from "../../../utilities/_module.js"; /** * IMPORT_PATH: `"@daiso-tech/core/circuit-breaker/middlewares"` * @group Middleware */ export function circuitBreakerMiddlewareFactory(circuitBreakerFactory) { return (settings) => { const { key = (...args) => JSON.stringify(args), ...rest } = settings; return ({ next, args }) => { return circuitBreakerFactory .create(callInvokable(key, ...args), rest) .runOrFail(next); }; }; } //# sourceMappingURL=circuit-breaker-middleware-factory.js.map