Initial commit: NestJS meshtastic bridge bot

This commit is contained in:
2026-09-23 17:36:11 +00:00
commit 83e46b8f07
21 changed files with 6248 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
import {
BadRequestException,
Body,
Controller,
Get,
Post,
} from '@nestjs/common';
import { BROADCAST_ADDR } from './codec.js';
import { MeshService } from './mesh.service.js';
@Controller()
export class MeshController {
constructor(private readonly mesh: MeshService) {}
@Get('status')
status() {
return this.mesh.status();
}
@Post('send')
async send(@Body() body: { to?: string | number; text: string }) {
if (typeof body?.text !== 'string' || body.text.length === 0) {
throw new BadRequestException('text must be a non-empty string');
}
let to = BROADCAST_ADDR;
const t = body.to;
if (t !== undefined && t !== '!b' && t !== 'broadcast') {
const n = typeof t === 'number' ? t : Number(String(t));
if (!Number.isFinite(n))
throw new BadRequestException(
'to must be a decimal node number, "!b", or "broadcast"',
);
to = n;
}
return { id: await this.mesh.sendText(to, body.text) };
}
}