import { dynamic, fallback } from "@daiso-tech/core/resilience";
import { AsyncHooks } from "@daiso-tech/core/hooks";
await new AsyncHooks(
(a: number, b: number) => a / b,
[
// You pass callback function where you get access to the function arguments and context.
// The callback function must return a middleware.
dynamic((_args, _context) =>
fallback({
fallbackValue: 1,
}),
),
],
).invoke(1, 0);
The
dynamicis wrapper middleware that allows configuration of other middlewares dynamically based on the function arguments and context.IMPORT_PATH:
"@daiso-tech/core/resilience"