Skip to content

Commit

Permalink
Merge pull request #1498 from Dracks/master
Browse files Browse the repository at this point in the history
chore(): formated everything with npm run format
  • Loading branch information
kamilmysliwiec authored Oct 5, 2023
2 parents ac71b45 + 23f5640 commit b80aa9d
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/decorators/command-handler.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import { v4 } from 'uuid';
*
* @see https://docs.nestjs.com/recipes/cqrs#commands
*/
export const CommandHandler = (command: ICommand | (new (...args: any[]) => ICommand)): ClassDecorator => {
export const CommandHandler = (
command: ICommand | (new (...args: any[]) => ICommand),
): ClassDecorator => {
return (target: object) => {
if (!Reflect.hasOwnMetadata(COMMAND_METADATA, command)) {
Reflect.defineMetadata(COMMAND_METADATA, { id: v4() }, command);
Expand Down
6 changes: 4 additions & 2 deletions src/decorators/events-handler.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ import { v4 } from 'uuid';
*
* @see https://docs.nestjs.com/recipes/cqrs#events
*/
export const EventsHandler = (...events: (IEvent | (new (...args: any[]) => IEvent))[]): ClassDecorator => {
export const EventsHandler = (
...events: (IEvent | (new (...args: any[]) => IEvent))[]
): ClassDecorator => {
return (target: object) => {
events.forEach((event) => {
if (!Reflect.hasOwnMetadata(EVENT_METADATA, event)) {
Reflect.defineMetadata(EVENT_METADATA, { id: v4() }, event);
}
});

Reflect.defineMetadata(EVENTS_HANDLER_METADATA, events, target);
};
};
3 changes: 2 additions & 1 deletion src/helpers/default-command-pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Subject } from 'rxjs';
import { ICommand, ICommandPublisher } from '../interfaces';

export class DefaultCommandPubSub<CommandBase extends ICommand>
implements ICommandPublisher<CommandBase> {
implements ICommandPublisher<CommandBase>
{
constructor(private subject$: Subject<CommandBase>) {}

publish<T extends CommandBase>(command: T) {
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/default-get-event-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Type } from '@nestjs/common';

/**
* Null if the published class is not connected to any handler
* @param event
* @returns
* @param event
* @returns
*/
export const defaultGetEventId = <EventBase extends IEvent = IEvent>(
event: EventBase,
Expand All @@ -20,4 +20,4 @@ export const defaultReflectEventId = <
event: EventBase,
): string => {
return Reflect.getMetadata(EVENT_METADATA, event).id;
};
};
3 changes: 2 additions & 1 deletion src/helpers/default-pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Subject } from 'rxjs';
import { IEvent, IEventPublisher, IMessageSource } from '../interfaces';

export class DefaultPubSub<EventBase extends IEvent>
implements IEventPublisher<EventBase>, IMessageSource<EventBase> {
implements IEventPublisher<EventBase>, IMessageSource<EventBase>
{
constructor(private subject$: Subject<EventBase>) {}

publish<T extends EventBase>(event: T) {
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/default-query-pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Subject } from 'rxjs';
import { IQuery, IQueryPublisher } from '../interfaces';

export class DefaultQueryPubSub<QueryBase extends IQuery>
implements IQueryPublisher<QueryBase> {
implements IQueryPublisher<QueryBase>
{
constructor(private subject$: Subject<QueryBase>) {}

publish<T extends QueryBase>(query: T) {
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/commands/command-metadata.interface.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export interface CommandMetadata {
id: string;
}
}
2 changes: 1 addition & 1 deletion src/interfaces/queries/query-metadata.interface.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export interface QueryMetadata {
id: string;
}
}

0 comments on commit b80aa9d

Please sign in to comment.