Skip to content

Commit 35305fc

Browse files
wandertakerderberg
andauthored
feat: support mqtts protocol (#174)
Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com>
1 parent 7c47b72 commit 35305fc

File tree

8 files changed

+629
-28
lines changed

8 files changed

+629
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Property name | Reason | Fallback | Default
4040
## Supported protocols
4141

4242
* [AMQP](https://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol)
43-
* [MQTT](https://en.wikipedia.org/wiki/MQTT)
43+
* [MQTT and MQTTS](https://en.wikipedia.org/wiki/MQTT)
4444
* [Kafka](https://en.wikipedia.org/wiki/Apache_Kafka)
4545
* [WebSocket](https://en.wikipedia.org/wiki/WebSocket)
4646

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"supportedProtocols": [
7979
"amqp",
8080
"mqtt",
81+
"mqtts",
8182
"kafka",
8283
"kafka-secure",
8384
"ws"

template/config/common.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ default:
2525
durable: true
2626
autoDelete: true
2727
{%- endif %}
28-
{%- if asyncapi.server(params.server).protocol() === "mqtt" %}
28+
{%- if asyncapi.server(params.server).protocol() === "mqtt" or asyncapi.server(params.server).protocol() === "mqtts"%}
2929
mqtt:
30-
url: mqtt://{{ asyncapi.server(params.server).url() | replaceServerVariablesWithValues(asyncapi.server(params.server).variables()) | stripProtocol }}
30+
url: {{ asyncapi.server(params.server).protocol() }}://{{ asyncapi.server(params.server).url() | replaceServerVariablesWithValues(asyncapi.server(params.server).variables()) | stripProtocol }}
3131
topics: {{ asyncapi | channelNamesWithPublish | toMqttTopic | dump | safe }}
3232
qos:
3333
protocol: mqtt

template/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"hermesjs": "2.x",
1212
"hermesjs-router": "1.x",
1313
"asyncapi-validator": "3.0.0",
14-
{% if asyncapi.server(params.server).protocol() === 'mqtt' -%}
14+
{% if asyncapi.server(params.server).protocol() === 'mqtt' or asyncapi.server(params.server).protocol() === 'mqtts' -%}
1515
"hermesjs-mqtt": "2.x",
1616
{%- endif -%}
1717
{% if asyncapi.server(params.server).protocol() === 'kafka' or asyncapi.server(params.server).protocol() === 'kafka-secure' -%}

template/src/api/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const logger = require('./middlewares/logger');
99
const errorLogger = require('./middlewares/error-logger');
1010
const config = require('../lib/config');
1111
{%- set protocol = asyncapi.server(params.server).protocol() %}
12+
{%- if protocol === 'mqtts' %}
13+
{%- set protocol = 'mqtt' %}
14+
{%- endif %}
1215
const serverConfig = {{ protocol | getConfig }};
1316
const {{ protocol | getProtocol | capitalize }}Adapter = require('hermesjs-{{ protocol | getProtocol }}');
1417
{%- for channelName, channel in asyncapi.channels() %}

0 commit comments

Comments
 (0)