UNPKG

cqrs-eda

Version:

Lightweight CQRS and Event-Driven Architecture library using TypeScript decorators, handlers and typings. Perfect for scalable event-driven apps.

35 lines 1.43 kB
/** * Dynamically loads all decorated classes (Commands, Queries, Observers) * so that the internal registries are automatically populated. * * This must be called before using CommandHandler, QueryHandler, or ObserverHandler, * otherwise the handlers won't know about the decorated classes. * * Example without any dependency injection container: * ```ts * import { Utilities, Handlers } from "cqrs-eda"; * * async function bootstrap() { * // Load all decorated commands, queries, and observers * await Utilities.loadDecoratedClasses("src/application"); * * // Initialize handlers * const commandHandler = new Handlers.CommandHandler(); * const queryHandler = new Handlers.QueryHandler(); * const observerHandler = new Handlers.ObserverHandler(); * * // Use the handlers * const segment = await queryHandler.fire("GET_SEGMENT", { phrase: "Hello", accent: "american" }); * console.log(segment); * * await commandHandler.fire("SAVE_SEGMENT", { phrase: "Hello", accent: "american", videoUrl: "...", startTime: 0, endTime: 2 }); * await observerHandler.publish("SEGMENT.SAVED", { phrase: "Hello", accent: "american", ... }); * } * * bootstrap(); * ``` * * @param basePath The base path where decorated files are located (e.g. "src/application") */ export declare function loadDecoratedClasses(basePath: string): Promise<void>; //# sourceMappingURL=loadDecoratedClasses.d.ts.map