import { d as db, b as backups } from '../../admin/create-upload-progress-table/POST-C-OoiMoW.js';
import { eq } from 'drizzle-orm';

async function handler(req, res) {
  try {
    const { backupId } = req.params;
    if (!backupId) {
      return res.status(400).json({
        success: false,
        error: "Backup ID is required"
      });
    }
    const backupIdNum = parseInt(backupId, 10);
    if (isNaN(backupIdNum)) {
      return res.status(400).json({
        success: false,
        error: "Invalid backup ID"
      });
    }
    const backup = await db.select().from(backups).where(eq(backups.id, backupIdNum)).limit(1);
    if (backup.length === 0) {
      return res.status(404).json({
        success: false,
        error: "Backup not found"
      });
    }
    res.json({
      success: true,
      backup: backup[0]
    });
  } catch (error) {
    console.error("Backup fetch error:", error);
    res.status(500).json({
      success: false,
      error: "Failed to fetch backup",
      message: String(error)
    });
  }
}

export { handler as h };
