refactor(dns): move to core package (#4687)
This commit is contained in:
@@ -24,12 +24,10 @@ export const env = createEnv({
|
|||||||
message: `SECRET_ENCRYPTION_KEY must only contain hex characters${errorSuffix}`,
|
message: `SECRET_ENCRYPTION_KEY must only contain hex characters${errorSuffix}`,
|
||||||
}),
|
}),
|
||||||
NO_EXTERNAL_CONNECTION: createBooleanSchema(false),
|
NO_EXTERNAL_CONNECTION: createBooleanSchema(false),
|
||||||
ENABLE_DNS_CACHING: createBooleanSchema(false),
|
|
||||||
},
|
},
|
||||||
runtimeEnv: {
|
runtimeEnv: {
|
||||||
SECRET_ENCRYPTION_KEY: process.env.SECRET_ENCRYPTION_KEY,
|
SECRET_ENCRYPTION_KEY: process.env.SECRET_ENCRYPTION_KEY,
|
||||||
NODE_ENV: process.env.NODE_ENV,
|
NODE_ENV: process.env.NODE_ENV,
|
||||||
NO_EXTERNAL_CONNECTION: process.env.NO_EXTERNAL_CONNECTION,
|
NO_EXTERNAL_CONNECTION: process.env.NO_EXTERNAL_CONNECTION,
|
||||||
ENABLE_DNS_CACHING: process.env.ENABLE_DNS_CACHING,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
".": "./index.ts",
|
".": "./index.ts",
|
||||||
"./types": "./src/types.ts",
|
"./types": "./src/types.ts",
|
||||||
"./server": "./src/server.ts",
|
"./server": "./src/server.ts",
|
||||||
"./init-dns": "./src/dns.ts",
|
|
||||||
"./client": "./src/client.ts",
|
"./client": "./src/client.ts",
|
||||||
"./env": "./env.ts"
|
"./env": "./env.ts"
|
||||||
},
|
},
|
||||||
@@ -30,7 +29,6 @@
|
|||||||
"@homarr/core": "workspace:^0.1.0",
|
"@homarr/core": "workspace:^0.1.0",
|
||||||
"@paralleldrive/cuid2": "^3.1.0",
|
"@paralleldrive/cuid2": "^3.1.0",
|
||||||
"dayjs": "^1.11.19",
|
"dayjs": "^1.11.19",
|
||||||
"dns-caching": "^0.2.9",
|
|
||||||
"next": "16.0.10",
|
"next": "16.0.10",
|
||||||
"octokit": "^5.0.5",
|
"octokit": "^5.0.5",
|
||||||
"react": "19.2.3",
|
"react": "19.2.3",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Agent } from "undici";
|
|||||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
|
|
||||||
// The below import statement initializes dns-caching
|
// The below import statement initializes dns-caching
|
||||||
import "./dns";
|
import "@homarr/core/infrastructure/dns/init";
|
||||||
|
|
||||||
const logger = createLogger({ module: "fetchAgent" });
|
const logger = createLogger({ module: "fetchAgent" });
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,8 @@
|
|||||||
"./infrastructure/certificates": "./src/infrastructure/certificates/index.ts",
|
"./infrastructure/certificates": "./src/infrastructure/certificates/index.ts",
|
||||||
"./infrastructure/certificates/hostnames/db/sqlite": "./src/infrastructure/certificates/hostnames/db/sqlite.ts",
|
"./infrastructure/certificates/hostnames/db/sqlite": "./src/infrastructure/certificates/hostnames/db/sqlite.ts",
|
||||||
"./infrastructure/certificates/hostnames/db/mysql": "./src/infrastructure/certificates/hostnames/db/mysql.ts",
|
"./infrastructure/certificates/hostnames/db/mysql": "./src/infrastructure/certificates/hostnames/db/mysql.ts",
|
||||||
"./infrastructure/certificates/hostnames/db/postgresql": "./src/infrastructure/certificates/hostnames/db/postgresql.ts"
|
"./infrastructure/certificates/hostnames/db/postgresql": "./src/infrastructure/certificates/hostnames/db/postgresql.ts",
|
||||||
|
"./infrastructure/dns/init": "./src/infrastructure/dns/init.ts"
|
||||||
},
|
},
|
||||||
"typesVersions": {
|
"typesVersions": {
|
||||||
"*": {
|
"*": {
|
||||||
@@ -36,6 +37,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@t3-oss/env-nextjs": "^0.13.8",
|
"@t3-oss/env-nextjs": "^0.13.8",
|
||||||
"better-sqlite3": "^12.5.0",
|
"better-sqlite3": "^12.5.0",
|
||||||
|
"dns-caching": "^0.2.9",
|
||||||
"drizzle-orm": "^0.45.1",
|
"drizzle-orm": "^0.45.1",
|
||||||
"ioredis": "5.8.2",
|
"ioredis": "5.8.2",
|
||||||
"mysql2": "3.15.3",
|
"mysql2": "3.15.3",
|
||||||
|
|||||||
8
packages/core/src/infrastructure/dns/env.ts
Normal file
8
packages/core/src/infrastructure/dns/env.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { createBooleanSchema, createEnv } from "../env";
|
||||||
|
|
||||||
|
export const dnsEnv = createEnv({
|
||||||
|
server: {
|
||||||
|
ENABLE_DNS_CACHING: createBooleanSchema(false),
|
||||||
|
},
|
||||||
|
experimental__runtimeEnv: process.env,
|
||||||
|
});
|
||||||
@@ -2,7 +2,7 @@ import { DnsCacheManager } from "dns-caching";
|
|||||||
|
|
||||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||||
|
|
||||||
import { env } from "../env";
|
import { dnsEnv } from "./env";
|
||||||
|
|
||||||
// Add global type augmentation for homarr
|
// Add global type augmentation for homarr
|
||||||
declare global {
|
declare global {
|
||||||
@@ -23,6 +23,6 @@ global.homarr.dnsCacheManager ??= new DnsCacheManager({
|
|||||||
logger,
|
logger,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (env.ENABLE_DNS_CACHING) {
|
if (dnsEnv.ENABLE_DNS_CACHING) {
|
||||||
global.homarr.dnsCacheManager.initialize();
|
global.homarr.dnsCacheManager.initialize();
|
||||||
}
|
}
|
||||||
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
@@ -877,9 +877,6 @@ importers:
|
|||||||
dayjs:
|
dayjs:
|
||||||
specifier: ^1.11.19
|
specifier: ^1.11.19
|
||||||
version: 1.11.19
|
version: 1.11.19
|
||||||
dns-caching:
|
|
||||||
specifier: ^0.2.9
|
|
||||||
version: 0.2.9
|
|
||||||
next:
|
next:
|
||||||
specifier: 16.0.10
|
specifier: 16.0.10
|
||||||
version: 16.0.10(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(sass@1.96.0)
|
version: 16.0.10(@babel/core@7.28.5)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(sass@1.96.0)
|
||||||
@@ -926,6 +923,9 @@ importers:
|
|||||||
better-sqlite3:
|
better-sqlite3:
|
||||||
specifier: ^12.5.0
|
specifier: ^12.5.0
|
||||||
version: 12.5.0
|
version: 12.5.0
|
||||||
|
dns-caching:
|
||||||
|
specifier: ^0.2.9
|
||||||
|
version: 0.2.9
|
||||||
drizzle-orm:
|
drizzle-orm:
|
||||||
specifier: ^0.45.1
|
specifier: ^0.45.1
|
||||||
version: 0.45.1(@libsql/client-wasm@0.14.0)(@types/better-sqlite3@7.6.13)(@types/pg@8.16.0)(better-sqlite3@12.5.0)(gel@2.0.0)(mysql2@3.15.3)(pg@8.16.3)
|
version: 0.45.1(@libsql/client-wasm@0.14.0)(@types/better-sqlite3@7.6.13)(@types/pg@8.16.0)(better-sqlite3@12.5.0)(gel@2.0.0)(mysql2@3.15.3)(pg@8.16.3)
|
||||||
|
|||||||
Reference in New Issue
Block a user