3.0.0 • Published 1 month ago

@forlagshuset/nestjs-message-dispatcher v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month 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 month ago

2.0.2

2 months ago

2.0.1

2 months ago

2.0.0

2 months ago

1.0.10

7 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago