- Extract shared fitToGpx into connected-services/fit.ts (FIT is a Garmin open standard used by Wahoo, Coros, Garmin — not provider-specific) - Add importActivity() to sync/imports.server.ts so providers call one function instead of createActivity + recordImport separately; eliminates direct dependency on activities.server.ts from provider adapters - Update wahoo importer + webhook to use both shared helpers - Extract useHostElection(yjs) hook from useRouting so host election is independently testable without mounting the full routing stack - Add setDb() to journal db.ts for module-level injection in unit tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
14 lines
252 B
TypeScript
14 lines
252 B
TypeScript
import { createDb, type Database } from "@trails-cool/db";
|
|
|
|
let _db: Database | null = null;
|
|
|
|
export function getDb(): Database {
|
|
if (!_db) {
|
|
_db = createDb();
|
|
}
|
|
return _db;
|
|
}
|
|
|
|
export function setDb(db: Database | null): void {
|
|
_db = db;
|
|
}
|