Update packages and improve SSL generation

This commit is contained in:
LukeGus
2025-09-28 01:30:25 -05:00
parent a79b640914
commit 6eb304b8e4
3 changed files with 1989 additions and 1421 deletions

3379
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
import "dotenv/config";
import dotenv from "dotenv"; import dotenv from "dotenv";
import { promises as fs } from "fs"; import { promises as fs } from "fs";
import path from "path"; import path from "path";
import { fileURLToPath } from "url";
import { AutoSSLSetup } from "./utils/auto-ssl-setup.js"; import { AutoSSLSetup } from "./utils/auto-ssl-setup.js";
import { AuthManager } from "./utils/auth-manager.js"; import { AuthManager } from "./utils/auth-manager.js";
import { DataCrypto } from "./utils/data-crypto.js"; import { DataCrypto } from "./utils/data-crypto.js";
@@ -10,17 +10,27 @@ import { systemLogger, versionLogger } from "./utils/logger.js";
(async () => { (async () => {
try { try {
dotenv.config({ quiet: true });
const dataDir = process.env.DATA_DIR || "./db/data"; const dataDir = process.env.DATA_DIR || "./db/data";
const envPath = path.join(dataDir, ".env"); const envPath = path.join(dataDir, ".env");
try { try {
await fs.access(envPath); await fs.access(envPath);
const persistentConfig = dotenv.config({ path: envPath }); const persistentConfig = dotenv.config({ path: envPath, quiet: true });
if (persistentConfig.parsed) { if (persistentConfig.parsed) {
Object.assign(process.env, persistentConfig.parsed); Object.assign(process.env, persistentConfig.parsed);
} }
} catch {} } catch {}
const version = process.env.VERSION || "unknown"; let version = "unknown";
try {
const __filename = fileURLToPath(import.meta.url);
const packageJsonPath = path.join(path.dirname(__filename), "../../../package.json");
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf-8"));
version = packageJson.version || "unknown";
} catch (error) {
version = process.env.VERSION || "unknown";
}
versionLogger.info(`Termix Backend starting - Version: ${version}`, { versionLogger.info(`Termix Backend starting - Version: ${version}`, {
operation: "startup", operation: "startup",
version: version, version: version,

View File

@@ -18,6 +18,15 @@ export class AutoSSLSetup {
private static readonly ENV_FILE = path.join(AutoSSLSetup.DATA_DIR, ".env"); private static readonly ENV_FILE = path.join(AutoSSLSetup.DATA_DIR, ".env");
static async initialize(): Promise<void> { static async initialize(): Promise<void> {
if (process.env.ENABLE_SSL !== "true") {
systemLogger.info("SSL not enabled - skipping certificate generation", {
operation: "ssl_disabled_default",
enable_ssl: process.env.ENABLE_SSL || "undefined",
note: "Set ENABLE_SSL=true to enable SSL certificate generation",
});
return;
}
try { try {
if (await this.isSSLConfigured()) { if (await this.isSSLConfigured()) {
await this.logCertificateInfo(); await this.logCertificateInfo();
@@ -75,10 +84,6 @@ export class AutoSSLSetup {
} }
private static async generateSSLCertificates(): Promise<void> { private static async generateSSLCertificates(): Promise<void> {
systemLogger.info("Generating SSL certificates for local development...", {
operation: "ssl_cert_generation",
});
try { try {
try { try {
execSync("openssl version", { stdio: "pipe" }); execSync("openssl version", { stdio: "pipe" });