UNPKG

mediatr-ts

Version:

Mimic the famous MediatR csharp library see: (https://github.com/jbogard/MediatR)

30 lines (29 loc) 1.25 kB
import { RequestHandlerClass } from "../../interfaces/requestHandler.js"; import RequestData, { RequestDataClass } from "../requestData.js"; import { OrderedMapping, OrderedMappings } from "./orderedMappings.js"; type RequestHandlerMappingData = { handlerClass: RequestHandlerClass<RequestData<unknown>, unknown>; requestClass: RequestDataClass<unknown>; }; /** * Mapping for request handlers * * @exports */ export declare class RequestHandlerMappings extends OrderedMappings<RequestHandlerMappingData> { /** * Gets all mappings for a specific request if provided, otherwise returns all (sorted) mappings * * @throws Error if no mappings are found for specified argument * @param requestClass The request class to get mappings for * @returns The array of handler classes in the order in which they should be executed. */ getAll(requestClass?: RequestDataClass<unknown>): OrderedMapping<RequestHandlerMappingData>[]; /** * Throws an error if the request handler mapping already exists * @param requestClass The request class to check * @throws Error if the mapping already exists */ throwIfExistingTypeMappings(requestClass: RequestDataClass<unknown>): void; } export {};