2.0.2 • Published 5 months ago

@evva/nest-mqtt v2.0.2

Weekly downloads
-
License
SEE LICENSE IN <L...
Repository
github
Last release
5 months ago

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

Import the module wherever needed and inject the MqttService into your service for use.

@Module({
  imports: [MqttModule],
})
export class ExampleModule {
  constructor(private readonly mqttService: MqttService) {}
  
  public async example() {
    try {
      await this.mqttService.connect({
        host: '127.0.0.1',
        protocol: 'mqtt',
        port: 1883,
        username: 'test',
        password: 'test',
        autoSubscribe: true
      })
    } catch (e) {
      console.log(`Failed to connect: ${e}`)
    }
  }

  @Subscribe('exampleTopic')
  public onExampleTopicEvent(@Payload() payload: object) {
    console.log(payload)
  }
}

Tip: Use the autoSubscribe flag to automatically subscribe to all @Subscribe() decorators.

Stay in touch

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

License

Proprietary

2.0.2

5 months ago

2.0.1

5 months ago

2.0.0

5 months ago

1.2.1

6 months ago

1.2.0

7 months ago

1.1.0

7 months ago

1.0.4

8 months ago

1.0.2

10 months ago

1.0.1

11 months ago

1.0.0

11 months ago