import { d as db, a as adminUsers } from '../../admin/create-upload-progress-table/POST-C-OoiMoW.js';

async function handler(req, res) {
  try {
    const existingUsers = await db.select().from(adminUsers).limit(1);
    res.json({
      adminExists: existingUsers.length > 0,
      adminCount: existingUsers.length
    });
  } catch (error) {
    if (error?.code === "ER_NO_SUCH_TABLE" || error?.cause?.code === "ER_NO_SUCH_TABLE") {
      return res.json({
        adminExists: false,
        adminCount: 0,
        setupRequired: true
      });
    }
    console.error("Failed to check admin existence:", error);
    res.status(500).json({
      error: "Failed to check admin existence",
      message: String(error)
    });
  }
}

export { handler as h };
