import { getBoxProducts, getProducts } from 'lib/shopify';
import { NextResponse } from 'next/server';

export async function GET(request: Request) {
  try {
    // Get query parameters
    const { searchParams } = new URL(request.url);
    const type = searchParams.get('type');
    
    if (type === 'boxes') {
      const boxProducts = await getBoxProducts({});
      return NextResponse.json({ products: boxProducts });
    } else {
      const allProducts = await getProducts({});
      return NextResponse.json({ products: allProducts });
    }
  } catch (error) {
    console.error('Error fetching products:', error);
    return NextResponse.json({ error: 'Failed to fetch products' }, { status: 500 });
  }
} 