import pool from '../../../../lib/db/db';
import { NextRequest, NextResponse } from 'next/server';

export async function GET() {
  try {
    const [countries] = await pool.query(
      "SELECT * FROM countries_with_phone ORDER BY name"
    );
    
    return NextResponse.json({
      success: true,
      data: countries
    });
  } catch (error) {
    return NextResponse.json(
      { success: false, message: 'Error fetching countries' },
      { status: 500 }
    );
  }
}