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
+24 -1
View File
@@ -5,20 +5,35 @@ import {
Get,
Post,
} from '@nestjs/common';
import { ApiOperation, ApiProperty } from '@nestjs/swagger';
import { BROADCAST_ADDR } from './codec.js';
import { MeshService } from './mesh.service.js';
export class SendTextDto {
@ApiProperty({ description: 'Message text', example: 'hello' })
text!: string;
@ApiProperty({
required: false,
description:
'Decimal node number, "!b", or "broadcast" (defaults to broadcast)',
example: '!b',
})
to?: string | number;
}
@Controller()
export class MeshController {
constructor(private readonly mesh: MeshService) {}
@Get('status')
@ApiOperation({ summary: 'Bridge connection status' })
status() {
return this.mesh.status();
}
@Post('send')
async send(@Body() body: { to?: string | number; text: string }) {
@ApiOperation({ summary: 'Send a text message over the mesh' })
async send(@Body() body: SendTextDto) {
if (typeof body?.text !== 'string' || body.text.length === 0) {
throw new BadRequestException('text must be a non-empty string');
}
@@ -34,4 +49,12 @@ export class MeshController {
}
return { id: await this.mesh.sendText(to, body.text) };
}
@Get('channels')
@ApiOperation({
summary: "The device's Meshtastic channels (keys redacted)",
})
channels() {
return this.mesh.channels();
}
}