3.0.0 • Published 1 year ago

@forlagshuset/nestjs-message-dispatcher v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

NestJS interceptor for message dispatching

Library to facilitate message creation & sending

Usecase

module

Module({
  controllers: [TestController],
  providers: [
    LoggerService,
    MessageDispatcherInterceptor,
    {
      provide: AsyncLoggerProvider,
      useExisting: LoggerService,
    },
    {
      provide: Options,
      useValue: <Options>{
        subject,
        messageData: <Partial<Message>>{
          service: {
            type: MsgServiceType.App,
            id: serviceId,
          },
          action: {
            type: MsgActionType.Object,
          },
          object: {
            type: MsgObjectType.ErudioNamespace,
          },
        },
      },
    },
  ],
}).compile();

controller

@Controller('/test')
export class TestController {
  @MessageEventEmitter({
    objectIdGetter: (request) => request.params.id,
    action: Action.CREATED,
  })
  @Get(':id')
  async test(@Param() params: { id: string }): Promise<{ id: string }> {
    // do some action
    // Message created and event emitted on success calls.
  }
}
3.0.0

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.10

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago