Replace all db.run(sql, [params]) calls with db.prepare(sql).run(...params)
across all source modules and test files. Also remove the node-sqlite3-wasm
import from tests/db.test.ts and update the type annotation accordingly.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collect payloads in memory Map, flush to SQLite every 2 seconds
instead of on every message. Prevents DB lock and slowness with
high-volume brokers like Venus OS.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The discovery message handler was missing the payload parameter,
so topics were saved without their last value.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When a user checks a topic checkbox, a datapoint is automatically
created and the broker subscribes to that topic for live updates.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- src/db/index.ts: initDb/getDb/closeDb using node-sqlite3-wasm (pure WASM, no VS build required)
- src/db/migrations/001-initial.ts: creates all 9 tables with FK constraints and CHECK constraints
- tests/db.test.ts: 10 tests verifying WAL mode, FK cascade, all table columns, and constraint enforcement
- Switched from better-sqlite3 (requires Visual Studio on Windows) to node-sqlite3-wasm
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- package.json with express, better-sqlite3, mqtt, pg, bcrypt, jsonwebtoken, cors
- tsconfig.json targeting ES2022/commonjs
- src/index.ts with GET /health on port 4000
- vitest.config.ts for test runner configuration
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>