DB Package
@repo/db
Section titled “@repo/db”Shared database package providing a Kysely instance backed by Node.js built-in node:sqlite (DatabaseSync). Used by all JS apps in the monorepo.
Exports
Section titled “Exports”createDb<T>(path)— Creates a Kysely instance with WAL mode, busy timeout, and foreign keys enabledrunMigrations(path, migrations)— File-based migration runner
Custom Dialect
Section titled “Custom Dialect”Implements three classes to bridge node:sqlite to Kysely:
NodeSqliteDialect— Creates driver, query compiler, adapter, introspectorNodeSqliteDriver— Connection lifecycle and transactionsNodeSqliteConnection— Query execution (detects SELECT vs write statements)
Pragmas
Section titled “Pragmas”PRAGMA journal_mode = WAL -- Concurrent read/writePRAGMA busy_timeout = 5000 -- Wait on lock contentionPRAGMA foreign_keys = ON -- Enforce FK constraintsWhy node:sqlite?
Section titled “Why node:sqlite?”Avoids better-sqlite3 and its native C++ compilation requirement. Uses the Node.js built-in SQLite module available since Node 22.