Files
HealthLog/src/lib/jobs/boss-instance.ts
T
Marc-André Bombeck 38309932f3 Initial release v1.0.0
HealthLog — personal health-tracking PWA with weight, blood pressure,
pulse, mood tracking, medication compliance, Withings integration,
doctor report PDF export, and Dracula-themed UI.
2026-03-10 20:14:33 +01:00

18 lines
553 B
TypeScript

/**
* Global pg-boss instance accessor.
* Uses globalThis to share the instance across Turbopack chunks.
* Set by the reminder worker on startup, read by notification senders
* for scheduling delayed cleanup jobs.
*/
import type { PgBoss } from "pg-boss";
const BOSS_KEY = "__healthlog_pgboss__" as const;
export function setGlobalBoss(boss: PgBoss) {
(globalThis as Record<string, unknown>)[BOSS_KEY] = boss;
}
export function getGlobalBoss(): PgBoss | null {
return ((globalThis as Record<string, unknown>)[BOSS_KEY] as PgBoss) ?? null;
}