@forlagshuset/nestjs-message-dispatcher
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

[DEPRECATED]

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.
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @forlagshuset/nestjs-message-dispatcher

Weekly Downloads

29

Version

3.0.0

License

MIT

Unpacked Size

162 kB

Total Files

44

Last publish

Collaborators

  • kemorian
  • warszk
  • iapain
  • lukaszsiromski
  • daniel.wiadro
  • shardiwal