import { getServerVercelClient } from '@/src/lib/vercel';
import { createResponse, handleApiError } from '@/src/lib/api';
import { NextRequest } from 'next/server';

export async function GET(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
  try {
    const vercel = await getServerVercelClient();
    const { id } = await params;
    if (!id) {
      return createResponse(400, 'Deployment ID is required');
    }

    const deployment = await vercel.deployments.getDeployment({ idOrUrl: id });
    return createResponse(200, 'Deployment retrieved successfully', { data: deployment });
  } catch (error) {
    return handleApiError(error);
  }
}
