mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 21:10:59 +00:00
refactor(boot): register the offline-geo notice from its own helper
Keeps register() under the function-size cap; the test pins that register() still calls it.
This commit is contained in:
1 parent
0139c22ae3
commit
e84b80ee3c
2 files changed
+21
-10
No files matched your search
+16
-10
@@ -1,5 +1,20 @@
|
||||
import type { Instrumentation } from "next";
|
||||
|
||||
/**
|
||||
* The admin notice for a host whose login-IP lookups leave it. The geo
|
||||
* resolver evaluates it on its first public-IP lookup; it holds a slot
|
||||
* rather than importing the notification layer (see the notice module).
|
||||
*/
|
||||
async function registerOfflineGeoNoticeAtBoot(): Promise<void> {
|
||||
try {
|
||||
const { registerOfflineGeoNotice } =
|
||||
await import("@/lib/notifications/offline-geo-notice");
|
||||
registerOfflineGeoNotice();
|
||||
} catch {
|
||||
// Without it the lookups still resolve; only the notice is missing.
|
||||
}
|
||||
}
|
||||
|
||||
export async function register() {
|
||||
// Only start the worker on the Node.js server runtime (not Edge, not build)
|
||||
if (process.env.NEXT_RUNTIME === "nodejs") {
|
||||
@@ -35,16 +50,7 @@ export async function register() {
|
||||
// A readiness summary must never break boot.
|
||||
}
|
||||
|
||||
// The admin notice for a host whose login-IP lookups leave it. The geo
|
||||
// resolver evaluates it on its first public-IP lookup; it holds a slot
|
||||
// rather than importing the notification layer (see the notice module).
|
||||
try {
|
||||
const { registerOfflineGeoNotice } =
|
||||
await import("@/lib/notifications/offline-geo-notice");
|
||||
registerOfflineGeoNotice();
|
||||
} catch {
|
||||
// Without it the lookups still resolve; only the notice is missing.
|
||||
}
|
||||
await registerOfflineGeoNoticeAtBoot();
|
||||
|
||||
// Does the configured encryption key open this database? A process whose
|
||||
// key does not refuses every API request with one clear 503 and starts
|
||||
|
||||
@@ -201,6 +201,11 @@ describe("offline-geo runtime detection", () => {
|
||||
expect(boot).toMatch(
|
||||
/import\("@\/lib\/notifications\/offline-geo-notice"\)[\s\S]*registerOfflineGeoNotice\(\)/,
|
||||
);
|
||||
// …and the helper that does it runs inside `register()`.
|
||||
const registerBody = boot.slice(
|
||||
boot.indexOf("export async function register()"),
|
||||
);
|
||||
expect(registerBody).toContain("await registerOfflineGeoNoticeAtBoot()");
|
||||
});
|
||||
|
||||
it("offlineGeoReady() is false when the .empty marker is present", async () => {
|
||||
|
||||
Reference in new issue
Block a user