refactor: switch from better-sqlite3 to node:sqlite (zero dependencies)

better-sqlite3 native addon fails on Node v25. Node.js built-in SQLite
(node:sqlite) has an identical synchronous API and requires no compilation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-10 21:20:24 +10:00
co-authored by Claude Opus 4.6
parent 43daf8162c
commit 566a01a6bd
3 changed files with 7 additions and 464 deletions
+5 -4
View File
@@ -1,5 +1,6 @@
// keys.mjs — API key management and usage tracking for OCP LAN mode
import Database from "better-sqlite3";
// Uses Node.js built-in SQLite (node:sqlite) — zero external dependencies.
import { DatabaseSync } from "node:sqlite";
import { randomBytes } from "node:crypto";
import { join } from "node:path";
import { mkdirSync } from "node:fs";
@@ -13,9 +14,9 @@ let db;
export function getDb() {
if (!db) {
db = new Database(DB_PATH);
db.pragma("journal_mode = WAL");
db.pragma("foreign_keys = ON");
db = new DatabaseSync(DB_PATH);
db.exec("PRAGMA journal_mode = WAL");
db.exec("PRAGMA foreign_keys = ON");
initSchema();
}
return db;