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
+23 -1
View File
@@ -1,9 +1,31 @@
import { NestFactory } from '@nestjs/core';
import type { NestExpressApplication } from '@nestjs/platform-express';
import type { RequestHandler } from 'express';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { apiReference } from '@scalar/nestjs-api-reference';
import * as pkg from '../package.json';
import { AppModule } from './app.module.js';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const app = await NestFactory.create<NestExpressApplication>(AppModule);
app.enableShutdownHooks();
app.setGlobalPrefix('api');
// Scalar API docs at / (OpenAPI JSON at /docs-json), outside the api prefix.
const docConfig = new DocumentBuilder()
.setTitle('MeshBot API')
.setDescription(
'Meshtastic bridge bot: status, send text messages, list device channels.',
)
.setVersion(pkg.version)
.build();
const document = SwaggerModule.createDocument(app, docConfig);
const http = app.getHttpAdapter().getInstance();
http.get('/docs-json', (_req, res) => {
res.json(document);
});
http.get('/', apiReference({ url: '/docs-json' }) as RequestHandler);
await app.listen(process.env.PORT ?? 3000);
}
bootstrap();