feat: /api/channels endpoint, /api namespace, Scalar at root (v0.1.0) (#2)

feat: /api/channels endpoint, /api namespace, Scalar at root (v0.1.0) — closes #1
This commit was merged in pull request #2.
This commit is contained in:
2026-09-23 21:05:22 +02:00
parent 5a33e4590a
commit 75a10c195f
11 changed files with 489 additions and 19 deletions
+13 -5
View File
@@ -21,13 +21,20 @@ Exposed via Traefik only (no published ports) at `http://bot.dev.kkhost.pl`.
## Endpoints
- `GET /status` — `{ connected, myNodeNum, host, port }`
- `POST /send` — body `{ "text": "...", "to"?: <node number | "!b" | "broadcast"> }`, returns `{ id }`
All API endpoints live under the `/api` prefix:
- `GET /api/status` — `{ connected, myNodeNum, host, port }`
- `POST /api/send` — body `{ "text": "...", "to"?: <node number | "!b" | "broadcast"> }`, returns `{ id }`
- `GET /api/channels` — the device's Meshtastic channels as `{ index, name, uplinkEnabled, downlinkEnabled }[]` (psk/keys are redacted; empty until the initial sync completes)
Interactive API docs (Scalar) are served at `/`, with the OpenAPI JSON at
`/docs-json`.
```sh
curl http://localhost:3000/status
curl -X POST http://localhost:3000/send -H 'content-type: application/json' -d '{"text":"hi"}'
curl -X POST http://localhost:3000/send -H 'content-type: application/json' -d '{"to":123456789,"text":"hello"}'
curl http://localhost:3000/api/status
curl -X POST http://localhost:3000/api/send -H 'content-type: application/json' -d '{"text":"hi"}'
curl -X POST http://localhost:3000/api/send -H 'content-type: application/json' -d '{"to":123456789,"text":"hello"}'
curl http://localhost:3000/api/channels
```
`to` omitted, `"!b"`, or `"broadcast"` sends to the broadcast address `0xffffffff`.
@@ -36,6 +43,7 @@ curl -X POST http://localhost:3000/send -H 'content-type: application/json' -d '
- `MESH_HOST` (default `192.168.1.4`) — bridge host
- `MESH_PORT` (default `4003`) — bridge port
- `MESH_RECONNECT_MS` (default `5000`) — reconnect interval in ms
- `PORT` (default `3000`) — HTTP listen port
Note: the serial bridge accepts only ONE client at a time — if another app is