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

Commit aa70e2a

Browse files
authored
Aedescli (#19)
* add aedes cli * more logging
1 parent c5b7bfd commit aa70e2a

File tree

6 files changed

+1231
-25
lines changed

6 files changed

+1231
-25
lines changed

.vscode/settings.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
{
2-
"debug.internalConsoleOptions": "neverOpen"
3-
}
2+
"debug.internalConsoleOptions": "neverOpen",
3+
"vsmqtt.brokerProfiles": [
4+
{
5+
"name": "devicescript gateway",
6+
"host": "0.0.0.0",
7+
"port": 1883,
8+
"clientId": "vsmqtt_client"
9+
}
10+
]
11+
}

dev.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env zx
2-
import 'zx/globals'
2+
import "zx/globals"
33
import dotenv from "dotenv"
44
import { expand } from "dotenv-expand"
55
import { networkInterfaces } from "os"
@@ -49,6 +49,15 @@ else if (!azure) {
4949
process.env.WEBSITE_HOSTNAME = `${address}:${port}`
5050
}
5151

52+
if (process.env.DEVS_MQTT_SERVER_DEV) {
53+
process.env.DEVS_MQTT_SERVER = `mqtt://${process.env.WEBSITE_HOSTNAME}:1883`
54+
$`yarn mqtt`
55+
console.log(`started development MQTT server`)
56+
console.warn(
57+
`- make sure to change the visibility of port '1883', '3000' to 'Public'`
58+
)
59+
}
60+
5261
expand(out)
5362

5463
if (!azure) {

local.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ DEVS_STORAGE_CONNECTION_STRING="DefaultEndpointsProtocol=http;AccountName=devsto
66
DEVS_PASSWORDS_SECRET="DEVS_LOCAL_USER_PASSWORD"
77
DEVS_LOCAL_USER_PASSWORD="devstoreaccount1:Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
88
DEVS_CONNECTION_STRING="AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;ApiRoot=$WEBSITE_PROTOCOL://$WEBSITE_HOSTNAME"
9-
DEVS_MQTT_SERVER="mqtt://public.mqtthq.com:1883"
9+
DEVS_MQTT_SERVER_DEV="1"

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"dev": "yarn build && zx dev.mjs --local",
2323
"dev:azure": "yarn build && zx dev.mjs --azure",
2424
"logs": "node infra/logs.mjs",
25-
"deploy": "node infra/zipdeploy.mjs"
25+
"deploy": "node infra/zipdeploy.mjs",
26+
"mqtt": "yarn aedes start --protos tcp ws --host 0.0.0.0 --broker-id devicescript-gateway --verbose"
2627
},
2728
"dependencies": {
2829
"@azure/data-tables": "^13.2.0",
@@ -36,6 +37,7 @@
3637
"@fastify/static": "^6.5.0",
3738
"@fastify/websocket": "^7.1.0",
3839
"aedes": "^0.48.0",
40+
"aedes-cli": "^0.6.1",
3941
"applicationinsights": "^2.5.0",
4042
"dotenv-expand": "^10.0.0",
4143
"fastify": "^4.9.2",

src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,13 @@ async function main() {
150150
<body>
151151
<h1>Development DeviceScript Gateway</h1>
152152
<ul>
153-
<li>Open <a href='./swagger/'>OpenAPI dashboard (swagger)</a>.</li>
153+
<li><a href='./swagger/'>OpenAPI dashboard (swagger)</a>.</li>
154154
<li><a href='https://microsoft.github.io/devicescript/developer/cloud/gateway'>Documentation</a></li>
155+
${
156+
process.env.DEVS_MQTT_SERVER
157+
? `<li>MQTT server: ${process.env.DEVS_MQTT_SERVER}</li>`
158+
: ""
159+
}
155160
</ul>
156161
</body>
157162
</html>`

0 commit comments

Comments
 (0)