# @htblaleonie/leonie-mqtt

> Leonie Mqtt Client to send and receive Mqtt messages easier

Latest version **1.0.5** (published 2021-05-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @htblaleonie/leonie-mqtt
pnpm add @htblaleonie/leonie-mqtt
yarn add @htblaleonie/leonie-mqtt
bun add @htblaleonie/leonie-mqtt
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2021-05-07 |
| First published | 2020-12-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jonas Dorfinger |
| Maintainers | htblaleonie |

## Links

- npm: https://www.npmjs.com/package/@htblaleonie/leonie-mqtt
- Repository: https://github.com/htblaleonie/leonie-mqtt
- Homepage: https://github.com/htblaleonie/leonie-mqtt#readme
- Issues: https://github.com/htblaleonie/leonie-mqtt/issues
- npm.io page: https://npm.io/package/@htblaleonie/leonie-mqtt

## Dependencies (1)

- [mqtt](https://npm.io/package/mqtt.md) ^4.2.5

## Recent versions

- 1.0.5 (latest) — 2021-05-07
- 1.0.4 — 2021-01-27
- 1.0.3 — 2020-12-01
- 1.0.2 — 2020-12-01
- 1.0.1 — 2020-12-01
- 1.0.0 — 2020-12-01

## README

# leonie-mqtt

The Leonie MQTT-Client. It has a type safe API for sending and receiving MQTT messages easier.

## Usage

### Install

```shell
npm i @htblaleonie/leonie-mqtt
```

### Create instance

```javascript
import MqttClient from '@htblaleonie/leonie-mqtt';

const client = new MqttClient(config.mqttUrl);
```

### Publish

```javascript
client.publish(token, topic, payload, err => {
    if (err) {
        console.error(err);
    }
});
```

#### Params:

- ``token``
- ``topic``
- ``payload``
- ``callback(err)``

### Subscribe

```javascript
client.subscribe(token, topic, (topic, message, err) => {
    if (err) {
        console.error(err);
    } else {
        console.log(message.toString());
    }
});
```

#### Params:

- ``token``
- ``topic``
- ``callback(topic, message, err)``

## Building and publishing

To easily make this code available to other teams, it's being published on `npm`. Effectively, this means that everything in this folder is public!

To publish a new version on `npm`

1. Increment the version in the `package.json` (we are using semantic versioning)
2. Run `npm publish`

<br>

<hr>

Copyright © 2020 - 2021, Jonas Dorfinger. This package is [MIT licensed](./LICENSE)

---
_Source: https://npm.io/package/@htblaleonie/leonie-mqtt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
