import { readFileSync } from 'fs';
import { join } from 'path';

async function handler(req, res) {
  try {
    const packagePath = join(process.cwd(), "package.json");
    const packageJson = JSON.parse(readFileSync(packagePath, "utf-8"));
    res.json({
      success: true,
      version: packageJson.version,
      name: packageJson.name,
      buildDate: "2026-01-12T05:23:00Z",
      // Updated with each build
      fixes: [
        "User display system (fixed React conditional props)",
        "Database migration SQL comment filtering",
        "Setup status persistence (API response structure)",
        "Dropdown navigation (React Router integration)",
        "Browser compatibility (no process.env references)",
        "Help button (opens documentation in new tab)",
        "Logout functionality (localStorage-based session)",
        "Dedicated login page (separate from setup wizard)",
        "Post-setup routing (login page instead of setup)"
      ]
    });
  } catch (error) {
    res.status(500).json({
      success: false,
      error: "Failed to get version",
      message: String(error)
    });
  }
}

export { handler as h };
