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

async function handler(req, res) {
  try {
    const allDevices = await db.select().from(devices).orderBy(desc(devices.lastSeen));
    res.json({
      success: true,
      devices: allDevices
    });
  } catch (error) {
    console.error("Devices fetch error:", error);
    res.status(500).json({
      success: false,
      error: "Failed to fetch devices",
      message: String(error)
    });
  }
}

export { handler as h };
