refactor(dns): move to core package (#4687)
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
import { DnsCacheManager } from "dns-caching";
|
||||
|
||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||
|
||||
import { env } from "../env";
|
||||
|
||||
// Add global type augmentation for homarr
|
||||
declare global {
|
||||
var homarr: {
|
||||
dnsCacheManager?: DnsCacheManager;
|
||||
// add other properties if needed
|
||||
};
|
||||
}
|
||||
|
||||
const logger = createLogger({ module: "dns" });
|
||||
|
||||
// Initialize global.homarr if not present
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
global.homarr ??= {};
|
||||
global.homarr.dnsCacheManager ??= new DnsCacheManager({
|
||||
cacheMaxEntries: 1000,
|
||||
forceMinTtl: 5 * 60 * 1000, // 5 minutes
|
||||
logger,
|
||||
});
|
||||
|
||||
if (env.ENABLE_DNS_CACHING) {
|
||||
global.homarr.dnsCacheManager.initialize();
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { Agent } from "undici";
|
||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||
|
||||
// The below import statement initializes dns-caching
|
||||
import "./dns";
|
||||
import "@homarr/core/infrastructure/dns/init";
|
||||
|
||||
const logger = createLogger({ module: "fetchAgent" });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user