mediatr-ts
Version:
Mimic the famous MediatR csharp library see: (https://github.com/jbogard/MediatR)
20 lines • 806 B
JavaScript
import { typeMappings } from "../models/mappings/index.js";
/**
* Decorate the requestHandler with this attribute
*
* @param value The request type
*/
var requestHandler = function (value) {
return function (target) {
var existingTypeMappings = typeMappings.requestHandlers.getAll().filter(function (x) { return x.requestClass === value; });
if (existingTypeMappings.length > 0) {
throw new Error("Request handler for ".concat(value.name, " has been defined twice. Make sure you only have one @requestHandler decorator for each request type."));
}
typeMappings.requestHandlers.add({
requestClass: value,
handlerClass: target
});
};
};
export default requestHandler;
//# sourceMappingURL=requestHandler.attribute.js.map