@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.
26 lines • 882 B
JavaScript
/**
* @module Lock
*/
import { v4 } from "uuid";
import {} from "../../../lock/contracts/_module.js";
import {} from "../../../middleware/contracts/_module.js";
import {} from "../../../time-span/contracts/time-span.contract.js";
import { callInvokable } from "../../../utilities/_module.js";
/**
* IMPORT_PATH: `"@daiso-tech/core/lock/middlewares"`
* @group Middleware
*/
export function lockMiddlewareFactory(lockFactory) {
return (settings) => {
const { key = (...args) => JSON.stringify(args), lockId = () => v4(), ...rest } = settings;
return ({ next, args }) => {
return lockFactory
.create(callInvokable(key, ...args), {
...rest,
lockId: callInvokable(lockId, ...args),
})
.runOrFail(next);
};
};
}
//# sourceMappingURL=lock-middleware-factory.js.map