# mqtt-stats

> MQTT Stats for Node.js

Latest version **0.0.4** (published 2016-05-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install mqtt-stats
pnpm add mqtt-stats
yarn add mqtt-stats
bun add mqtt-stats
```

Provides the command `crispy-stats`.

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2016-05-30 |
| First published | 2016-05-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Fabio Bellini |
| Maintainers | fabecm |
| Keywords | "mqtt", "client", "node.js", "stats", "analitycs" |

## Links

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

## Dependencies (2)

- [mqtt](https://npm.io/package/mqtt.md) ^1.10.0
- [lodash](https://npm.io/package/lodash.md) ^4.13.1

## Recent versions

- 0.0.4 (latest) — 2016-05-30
- 0.0.3 — 2016-05-27
- 0.0.2 — 2016-05-27
- 0.0.1 — 2016-05-27

## README

# mqtt-stats
MQTT Stats for Node.js

The goal of this lib is to simplify the creation of custom and lightweight stats/analytics for Node.js web apps.

One usage example of this lib is an internet connected Board with one Led for every node.js app, if the node application goes offline the relative led in the Board will go off. 

## Methods
######   **init**(_name_, _host_, _mqttObject_)

  **Params:**
  
    
    name: 
      
      Name of the Project
  
    host: 
      
      Host of MQTT broker (See MQTT.js)
  
    mqttObject: 
      
      Object of MQTT Client configuration. (See MQTT.js)


  **Description:**
  
    This method initialize the lib and subscribe the mqtt client to the topic "[PROJECT_NAME]/presence",
    In case of publish on "[PROJECT_NAME]/presence" the client will publish on "[PROJECT_NAME]"
  
######   **express**(_req_, _res_)

  **Use:**
    
    var stats = require("mqtt-stats");
    
    var app = express();
  
    app.use(stats.express);

  **Description:**
  
    This method will publish to "[PROJECT_NAME]/calls" every Express response
######   **episode**(_eventName_, _data_)

  **Params:**
      
    eventName: 
      
      The name of the Event
  
    data: 
    
      The payload of the publish

  **Description:**
  
    This method will publish to "[PROJECT_NAME]/episode/[EVENT_NAME]" on specific episodes (ex. A new login, new post, new user, ecc)

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