mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-27 17:00:54 +01:00
27 lines
633 B
TypeScript
27 lines
633 B
TypeScript
import { DnsCacheManager } from "dns-caching";
|
|
|
|
import { logger } from "@homarr/log";
|
|
|
|
import { env } from "../env";
|
|
|
|
// Add global type augmentation for homarr
|
|
declare global {
|
|
var homarr: {
|
|
dnsCacheManager?: DnsCacheManager;
|
|
// add other properties if needed
|
|
};
|
|
}
|
|
|
|
// 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();
|
|
}
|