Socket
Socket
Sign inDemoInstall

@nestjs/cqrs

Package Overview
Dependencies
13
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.3

cqrs.module.d.ts

12

command-bus.d.ts
import 'reflect-metadata';
import { ModuleRef } from 'nest.js';
import { ICommandBus, ICommand, ICommandHandler } from './interfaces/index';
import { ObservableBus } from './utils/observable-bus';
import { Metatype } from 'nest.js/common/interfaces';
import { Metatype } from '@nestjs/common/interfaces';
export declare type CommandHandlerMetatype = Metatype<ICommandHandler<ICommand>>;
export declare class CommandBus extends ObservableBus<ICommand> implements ICommandBus {
private readonly moduleRef;
private handlers;
constructor(moduleRef: ModuleRef);
private moduleRef;
setModuleRef(moduleRef: any): void;
execute<T extends ICommand>(command: T): Promise<any>;
bind<T extends ICommand>(handler: ICommandHandler<T>, name: string): void;
register(handlers: Metatype<ICommandHandler<ICommand>>[]): void;
protected registerHandler(handler: Metatype<ICommandHandler<ICommand>>): void;
register(handlers: CommandHandlerMetatype[]): void;
protected registerHandler(handler: CommandHandlerMetatype): void;
private getCommandName(command);
private reflectCommandName(handler);
}

@@ -8,8 +8,5 @@ "use strict";

};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
require("reflect-metadata");
const nest_js_1 = require("nest.js");
const common_1 = require("@nestjs/common");
const command_not_found_exception_1 = require("./exceptions/command-not-found.exception");

@@ -20,7 +17,10 @@ const observable_bus_1 = require("./utils/observable-bus");

let CommandBus = class CommandBus extends observable_bus_1.ObservableBus {
constructor(moduleRef) {
super();
this.moduleRef = moduleRef;
constructor() {
super(...arguments);
this.handlers = new Map();
this.moduleRef = null;
}
setModuleRef(moduleRef) {
this.moduleRef = moduleRef;
}
execute(command) {

@@ -43,2 +43,5 @@ const handler = this.handlers.get(this.getCommandName(command));

registerHandler(handler) {
if (!this.moduleRef) {
throw new index_1.InvalidModuleRefException();
}
const instance = this.moduleRef.get(handler);

@@ -62,5 +65,4 @@ if (!instance)

CommandBus = __decorate([
nest_js_1.Component(),
__metadata("design:paramtypes", [nest_js_1.ModuleRef])
common_1.Component()
], CommandBus);
exports.CommandBus = CommandBus;
import { IEventBus, IEvent, IEventHandler } from './interfaces/index';
import { ObservableBus } from './utils/observable-bus';
import { Metatype } from 'nest.js/common/interfaces';
import { ModuleRef } from 'nest.js';
import { Metatype } from '@nestjs/common/interfaces';
import { EventObservable } from './interfaces/event-observable.interface';

@@ -9,7 +8,9 @@ import { Observable } from 'rxjs/Observable';

import 'rxjs/add/operator/filter';
export declare type EventHandlerMetatype = Metatype<IEventHandler<IEvent>>;
export declare type Saga = (events$: EventObservable<IEvent>) => any;
export declare class EventBus extends ObservableBus<IEvent> implements IEventBus {
private readonly moduleRef;
private readonly commandBus;
constructor(moduleRef: ModuleRef, commandBus: CommandBus);
private moduleRef;
constructor(commandBus: CommandBus);
setModuleRef(moduleRef: any): void;
publish<T extends IEvent>(event: T): void;

@@ -21,4 +22,4 @@ ofType<T extends IEvent>(event: T & {

combineSagas(sagas: Saga[]): void;
register(handlers: Metatype<IEventHandler<IEvent>>[]): void;
protected registerHandler(handler: Metatype<IEventHandler<IEvent>>): void;
register(handlers: EventHandlerMetatype[]): void;
protected registerHandler(handler: EventHandlerMetatype): void;
protected ofEventName(name: string): Observable<IEvent>;

@@ -25,0 +26,0 @@ private getEventName(event);

@@ -13,3 +13,3 @@ "use strict";

const observable_bus_1 = require("./utils/observable-bus");
const nest_js_1 = require("nest.js");
const common_1 = require("@nestjs/common");
const Observable_1 = require("rxjs/Observable");

@@ -19,9 +19,13 @@ const command_bus_1 = require("./command-bus");

const constants_1 = require("./utils/constants");
const index_1 = require("./index");
require("rxjs/add/operator/filter");
let EventBus = class EventBus extends observable_bus_1.ObservableBus {
constructor(moduleRef, commandBus) {
constructor(commandBus) {
super();
this.moduleRef = moduleRef;
this.commandBus = commandBus;
this.moduleRef = null;
}
setModuleRef(moduleRef) {
this.moduleRef = moduleRef;
}
publish(event) {

@@ -44,2 +48,5 @@ this.subject$.next(event);

registerHandler(handler) {
if (!this.moduleRef) {
throw new index_1.InvalidModuleRefException();
}
const instance = this.moduleRef.get(handler);

@@ -70,6 +77,5 @@ if (!instance)

EventBus = __decorate([
nest_js_1.Component(),
__metadata("design:paramtypes", [nest_js_1.ModuleRef,
command_bus_1.CommandBus])
common_1.Component(),
__metadata("design:paramtypes", [command_bus_1.CommandBus])
], EventBus);
exports.EventBus = EventBus;

@@ -12,3 +12,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const nest_js_1 = require("nest.js");
const common_1 = require("@nestjs/common");
const event_bus_1 = require("./event-bus");

@@ -36,5 +36,5 @@ let EventPublisher = class EventPublisher {

EventPublisher = __decorate([
nest_js_1.Component(),
common_1.Component(),
__metadata("design:paramtypes", [event_bus_1.EventBus])
], EventPublisher);
exports.EventPublisher = EventPublisher;

@@ -5,1 +5,2 @@ export * from './command-not-found.exception';

export * from './invalid-events-handler.exception';
export * from './invalid-module-ref.exception';

@@ -10,1 +10,2 @@ "use strict";

__export(require("./invalid-events-handler.exception"));
__export(require("./invalid-module-ref.exception"));
export * from './aggregate-root';
export * from './command-bus';
export * from './event-bus';
export * from './event-publisher';
export * from './utils';
export * from './interfaces';
export * from './exceptions';
export * from './cqrs.module';

@@ -7,6 +7,4 @@ "use strict";

__export(require("./aggregate-root"));
__export(require("./command-bus"));
__export(require("./event-bus"));
__export(require("./event-publisher"));
__export(require("./utils"));
__export(require("./exceptions"));
__export(require("./cqrs.module"));
{
"name": "@nestjs/cqrs",
"version": "1.0.1",
"version": "1.0.3",
"description": "A lightweight CQRS module for Nest framework (node.js)",

@@ -8,3 +8,3 @@ "author": "Kamil Mysliwiec",

"peerDependencies": {
"nest.js": "*",
"@nestjs/common": "*",
"reflect-metadata": "0.1.10",

@@ -11,0 +11,0 @@ "rxjs": "5.*"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc