/** * The running version, from the backend's package.json (src/lib → ../../package.json in development, * dist/lib → ../../package.json when built), so /api/health tells `crosscode deploy` the truth * however the process was started (PM2 doesn't set npm_package_version). */ import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; let cached: string | null = null; export function appVersion(): string { if (!cached) { try { const file = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', 'package.json'); cached = (JSON.parse(fs.readFileSync(file, 'utf8')) as { version: string }).version; } catch { cached = '0.0.0'; } } return cached; }