Node database: collect nodes during sync, expose GET /api/nodes #7

Merged
kamilkrzywda merged 1 commits from feat/node-db into main 2026-09-24 15:37:03 +02:00
Owner

What

The service now keeps a node database built from the initial sync (FromRadio nodeInfo entries) plus live POSITION_APP packets, and exposes it over the API:

  • GET /api/nodes — all known nodes as { num, longName?, shortName?, hwModel?, batteryLevel?, lastHeard: number|null, position?: { lat, lon, alt? } }[]
  • GET /api/nodes/:id — lookup by exact node number/numeric string, then case-insensitive exact long/short name, else unique substring; 404 when missing or ambiguous

Details

  • mesh.service.ts: nodeMap reset on each connect, upserted from nodeInfo, POSITION_APP packets create stub entries for unknown nodes; public nodes() / node(idOrName) with JSDoc on all public methods; ready-log includes node count
  • codec.ts: decodePosition() (live positions arrive as a serialized Position inside Data.payload — there is no Data.position field in @meshtastic/protobufs v2.8), hw-model enum → name reverse lookup
  • Controller: full Swagger annotations on all 5 endpoints, @ApiTags('Mesh'), tag description via DocumentBuilder (v12 ApiTagOptions has no description field)
  • README + AGENTS.md endpoint lists updated

Verification

  • npm run build ✓
  • npm test — 18/18 passed (was 13, +5 new: node upsert, position stub, lookup resolution order, 404 paths)
  • v0.2.0, CHANGELOG entry added
## What The service now keeps a node database built from the initial sync (FromRadio `nodeInfo` entries) plus live POSITION_APP packets, and exposes it over the API: - `GET /api/nodes` — all known nodes as `{ num, longName?, shortName?, hwModel?, batteryLevel?, lastHeard: number|null, position?: { lat, lon, alt? } }[]` - `GET /api/nodes/:id` — lookup by exact node number/numeric string, then case-insensitive exact long/short name, else unique substring; 404 when missing or ambiguous ## Details - `mesh.service.ts`: nodeMap reset on each connect, upserted from `nodeInfo`, POSITION_APP packets create stub entries for unknown nodes; public `nodes()` / `node(idOrName)` with JSDoc on all public methods; ready-log includes node count - `codec.ts`: `decodePosition()` (live positions arrive as a serialized Position inside `Data.payload` — there is no `Data.position` field in @meshtastic/protobufs v2.8), hw-model enum → name reverse lookup - Controller: full Swagger annotations on all 5 endpoints, `@ApiTags('Mesh')`, tag description via DocumentBuilder (v12 ApiTagOptions has no description field) - README + AGENTS.md endpoint lists updated ## Verification - `npm run build` ✓ - `npm test` — 18/18 passed (was 13, +5 new: node upsert, position stub, lookup resolution order, 404 paths) - v0.2.0, CHANGELOG entry added
kamilkrzywda added 1 commit 2026-09-24 15:28:04 +02:00
kamilkrzywda merged commit 5292303786 into main 2026-09-24 15:37:03 +02:00
kamilkrzywda deleted branch feat/node-db 2026-09-24 15:37:03 +02:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: OpenCode/MeshBot#7