@nestjstools/messaging
Version:
Simplifies asynchronous and synchronous message handling with support for buses, handlers, channels, and consumers. Build scalable, decoupled applications with ease and reliability.
26 lines • 806 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseRegistry = void 0;
const messaging_exception_1 = require("../exception/messaging.exception");
class BaseRegistry {
constructor() {
this.registry = new Map();
}
register(name, middleware) {
if (this.registry.has(name)) {
return;
}
this.registry.set(name, middleware);
}
getByName(name) {
if (!this.registry.has(name)) {
throw new messaging_exception_1.MessagingException(`There is no element in registry with name: ${name}`);
}
return this.registry.get(name);
}
getAll() {
return Array.from(this.registry.values());
}
}
exports.BaseRegistry = BaseRegistry;
//# sourceMappingURL=base-registry.js.map