Persist message history to SQLite with 1s poller (#15) (#19)
CI / build + unit (push) Successful in 1m4s

This commit was merged in pull request #19.
This commit is contained in:
2026-09-25 02:46:17 +02:00
parent 756086d107
commit 74f3080626
10 changed files with 337 additions and 12 deletions
+19 -2
View File
@@ -1,10 +1,27 @@
import { Module } from '@nestjs/common';
import { mkdirSync } from 'node:fs';
import { dirname } from 'node:path';
import { DatabaseSync } from 'node:sqlite';
import { McpController } from './mcp.controller.js';
import { MeshController } from './mesh.controller.js';
import { MeshService } from './mesh.service.js';
import { initMessagesTable, MeshService } from './mesh.service.js';
// SQLite-backed message history: file path from MESH_DB_PATH (default ./data/mesh-bot.db), parent dir created if missing.
function openMessageDb(): DatabaseSync {
const path = process.env.MESH_DB_PATH ?? './data/mesh-bot.db';
mkdirSync(dirname(path), { recursive: true });
const db = new DatabaseSync(path);
initMessagesTable(db);
return db;
}
@Module({
controllers: [MeshController, McpController],
providers: [MeshService],
providers: [
{
provide: MeshService,
useFactory: () => new MeshService(openMessageDb()),
},
],
})
export class MeshModule {}