Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Commit 099350d

Browse files
committed
default to mqtthq
1 parent 370e5c0 commit 099350d

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

local.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ DEVS_LOCAL_USER_PASSWORD="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVE
77
DEVS_STORAGE_CONNECTION_STRING="DefaultEndpointsProtocol=http;AccountName=$DEVS_LOCAL_USER_NAME;AccountKey=$DEVS_LOCAL_USER_PASSWORD;BlobEndpoint=http://127.0.0.1:10000/$DEVS_LOCAL_USER_NAME;QueueEndpoint=http://127.0.0.1:10001/$DEVS_LOCAL_USER_NAME;TableEndpoint=http://127.0.0.1:10002/$DEVS_LOCAL_USER_NAME;"
88
DEVS_PASSWORDS="$DEVS_LOCAL_USER_NAME:$DEVS_LOCAL_USER_PASSWORD"
99
DEVS_CONNECTION_STRING="AccountName=$DEVS_LOCAL_USER_NAME;AccountKey=$DEVS_LOCAL_USER_PASSWORD;ApiRoot=$WEBSITE_PROTOCOL://$WEBSITE_HOSTNAME"
10-
DEVS_MQTT_SERVER_DEV="1"
10+
DEVS_MQTT_SERVER="mqtt://public.mqtthq.com:1883"

src/apigateway.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function initGatewayRoutes(server: FastifyInstance) {
1111
res.mqtt = {
1212
hostname: mqttUrl.hostname,
1313
path: mqttUrl.pathname,
14-
port: mqttUrl.port,
14+
port: Number(mqttUrl.port) || 1883,
1515
username: process.env.DEVS_MQTT_USER_NAME,
1616
password: process.env.DEVS_MQTT_USER_PASSWORD,
1717
}

src/mqtt.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ export async function setup() {
4343
topicName: "*",
4444
ingest: async (topic, message, device) => {
4545
if (!client.connected) return
46-
47-
const mqTopic = `${mqttTopicPrefix(device.dev)}/from/${topic}`
46+
47+
// don't rewrite global topics
48+
const mqTopic = /~\//.test(topic) ? topic.slice(1) : `${mqttTopicPrefix(device.dev)}/from/${topic}`
4849
client.publish(
4950
mqTopic,
5051
Buffer.from(JSON.stringify(message), "utf-8"),

src/swagger/openapi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function generateOpenApiSpec() {
6464
"URL of the MQTT server"
6565
),
6666
path: sString("URL path if any", "Path to the MQTT server"),
67-
port: sString("mqtt port", "Port to listen to"),
67+
port: sNumber("mqtt port", "Port to listen to"),
6868
username: sString(
6969
"MQTT user",
7070
"username to connect to MQTT server"

0 commit comments

Comments
 (0)