import fs from 'node:fs'; import path from 'node:path'; /** * Runtime configuration resolved from the environment. * * The static directory prefers the Vite production build (`dist/`) and falls * back to `public/` so a dev-mode server never 404s outright. */ export class AppConfig { readonly port: number; readonly host: string; readonly staticDir: string; constructor(env: Record = process.env, cwd: string = process.cwd()) { this.port = Number(env.PORT || 8080); this.host = env.HOST || '0.0.0.0'; const dist = path.join(cwd, 'dist'); this.staticDir = fs.existsSync(dist) ? dist : path.join(cwd, 'public'); } }