@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.
19 lines • 636 B
JavaScript
/**
* @module RateLimiter
*/
import {} from "../../../cache/contracts/_module.js";
import {} from "../../../middleware/contracts/_module.js";
import { callInvokable } from "../../../utilities/_module.js";
/**
* IMPORT_PATH: `"@daiso-tech/core/cache/middlewares"`
* @group Middleware
*/
export function cacheMiddlewareFactory(cache) {
return (settings) => {
const { key = (...args) => JSON.stringify(args), ...rest } = settings;
return async ({ next, args }) => {
return cache.getOrAdd(callInvokable(key, ...args), next, rest);
};
};
}
//# sourceMappingURL=cache-middleware-factory.js.map