Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(): formated everything with npm run format #1498

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}