mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-14 10:52:17 +03:00
20 lines
550 B
TypeScript
20 lines
550 B
TypeScript
import type { SqliteAdapter } from "./adapters/types";
|
|
|
|
declare global {
|
|
var __omnirouteDb: SqliteAdapter | undefined;
|
|
}
|
|
|
|
/** Read the process-wide DB handle without initializing storage. */
|
|
export function getExistingDbInstance(): SqliteAdapter | null {
|
|
return globalThis.__omnirouteDb ?? null;
|
|
}
|
|
|
|
/** Replace the process-wide DB handle while preserving it across Next.js HMR. */
|
|
export function setDbInstance(db: SqliteAdapter | null): void {
|
|
if (db) {
|
|
globalThis.__omnirouteDb = db;
|
|
} else {
|
|
delete globalThis.__omnirouteDb;
|
|
}
|
|
}
|