Skip to content

Commit

Permalink
Merge pull request #334 from Shurtu-gal/feat/mqtt-plugin
Browse files Browse the repository at this point in the history
feat(plugin): create MQTT plugin
  • Loading branch information
Shurtu-gal authored Feb 14, 2024
2 parents 99f3f5a + 3b8c249 commit 7cdf4e3
Show file tree
Hide file tree
Showing 38 changed files with 8,654 additions and 0 deletions.
19 changes: 19 additions & 0 deletions plugins/broker-mqtt/.amplicationrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"settings": {
"mqttPort": 1883,
"mqttWsPort": 8073,
"mqttWebUiPort": 8080,
"mqttBrokerHost": "localhost",
"mqttUsername": "admin",
"mqttPassword": "admin",
"mqttBroker": "emqx",
"sparkplugConfig": {
"enabled": false,
"edgeNodeIdentifier": "amplication-sparkplug-edge",
"groupIdentifier": "amplication-sparkplug-group"
}
},
"systemSettings": {
"requireAuthenticationEntity": "false"
}
}
4 changes: 4 additions & 0 deletions plugins/broker-mqtt/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"]
}
36 changes: 36 additions & 0 deletions plugins/broker-mqtt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Mac/OSX
.DS_Store

# Private Files
*.csv
*.csv.gz
*.tsv
*.tsv.gz
*.xlsx

# Build Files
dist/

# Private Node Modules
node_modules/
creds.js

# VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

# Common credential files
**/credentials.json
**/client_secrets.json
**/client_secret.json
*creds*
*.dat
*password*
*.httr-oauth*
2 changes: 2 additions & 0 deletions plugins/broker-mqtt/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.prettierignore
.gitignore
1 change: 1 addition & 0 deletions plugins/broker-mqtt/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
71 changes: 71 additions & 0 deletions plugins/broker-mqtt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# @amplication/plugin-broker-mqtt

[![NPM Downloads](https://img.shields.io/npm/dt/@amplication/plugin-broker-mqtt)](https://www.npmjs.com/package/@amplication/plugin-broker-mqtt)

This is a plugin for Amplication that adds basic support for MQTT broker.

## Purpose

It saves the developers the mess of boilerplate a new microservice with integration to MQTT broker. Also it adds subscription to the broker and added topics automatically to the app. This is done using the [Amplication Message Broker Services](https://docs.amplication.com/how-to/create-message-broker/) and [NestJS MQTT](https://docs.nestjs.com/microservices/mqtt).

## Configuration

This plugin allows you to configure the MQTT broker settings. The following values can be provided in the plugin settings to configure the MQTT broker.

>[!NOTE]
> These are optional settings and the plugin will work with default settings if not provided.
- `mqttBroker`: The name of the MQTT broker to be used. ( Optional, Default: `emqx`, Supported: `emqx`, `mosquitto`, `hivemq` and `hivemq-enterprise` )

- `mqttBrokerHost`: The host of the MQTT broker. ( Optional, Default: `localhost` )

- `mqttClientID`: The client ID to connect to the MQTT broker. ( Optional, Default: `broker-mqtt-(resourceID)` )

- `mqttPort`: The port of the MQTT broker. ( Optional, Default: `1883` )

- `mqttUsername`: The username to connect to the MQTT broker. ( Optional, Default: `admin` )

- `mqttPassword`: The password to connect to the MQTT broker. ( Optional, Default: `admin` )

- `mqttWsPort`: The port of the MQTT broker for WebSockets. This is used for the client or dashboard to connect to the broker. ( Optional, Default: `8073` )

- `mqttWebUiPort`: The port of the MQTT broker for the Web UI. This is where dashboard is served. ( Optional, Default: `8080` )

- `sparkplugConfig`: The configuration for the Sparkplug. This is used to configure the Sparkplug.

- `enabled`: Whether to enable the Sparkplug. ( Optional, Default: `false` )

- `groupIdentifier`: The group identifier for the Sparkplug. ( Optional, Default: `amplication-sparkplug-group` )

- `edgeNodeIdentifier`: The edge node identifier for the Sparkplug. ( Optional, Default: `amplication-sparkplug-edge` )

- `clientIdentifier`: The client identifier for the Sparkplug. ( Optional, Default: `amplication-sparkplug-client-(resource-id)` )


## Supported MQTT Brokers

This plugin supports the following MQTT brokers:

- [EMQX](https://www.emqx.io/)
Has builtin dashboard and websockets support.

- [Mosquitto](https://mosquitto.org/)
Doesn't have builtin dashboard hence the webUI port is not used.

- [HiveMQ](https://www.hivemq.com/)

- [HiveMQ Enterprise](https://www.hivemq.com/products/mqtt-broker/)

## Scripts

### `build`

Running `npm run build` will bundle your plugin with Webpack for production.

### `dev`

Running `npm run dev` will watch your plugin's source code and automatically bundle it with every change.

### `test`

Running `npm run test` will run the tests for your plugin.
Loading

0 comments on commit 7cdf4e3

Please sign in to comment.