Skip to content

Client implementation for an MQTT Broker that also supports shared subscriptions. Offers additional decorators to simply usage.

License

Notifications You must be signed in to change notification settings

evva-sfw/nest-mqtt

Repository files navigation

Nest MQTT

NPM Version NPM Downloads NPM Unpacked Size (with version) GitHub last commit GitHub branch check runs EVVA License

Install

npm i @evva/nest-mqtt

Description

Client implementation for an MQTT Broker that also supports shared subscriptions. Offers additional decorators to simply usage.

Build & Package

# Nest Build
$ nest build

Usage

  MqttModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (configService: ConfigService) =>
        ({
          host: configService.get<string>(BROKER_HOST),
          port: configService.get<Number>(BROKER_PORT, {'infer': true}),
          protocol: configService.get<string>(BROKER_PROTOCOL),
          username: configService.get<string>(BROKER_CLIENT_USER),
          password: configService.get<string>(
            BROKER_CLIENT_PASSWORD,
          ),
          share: configService.get<string>(BROKER_SHARED_PREFIX),
        }) as MqttModuleOptions,
    }),

When using the ConfigService, make sure that the variables are loaded before accessing them. This usually works as follows:

export class MyModule implements OnModuleInit {
  
  
  async onModuleInit() {
    await ConfigModule.envVariablesLoaded;
  }
}

Support

Stay in touch

  • Author - microud/nest-mqtt
  • Author - sfw-e

License

Proprietary

About

Client implementation for an MQTT Broker that also supports shared subscriptions. Offers additional decorators to simply usage.

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •