import { eq } from 'drizzle-orm';
import { NextResponse } from 'next/server';
import { db } from '@/db/drizzle';
import { moreProject } from '@/db/schema';

export const GET = async (
  req: Request,
  { params }: { params: { id: string } }
) => {
  try {
    const { id } = params;
    const rt = await db.select().from(moreProject).where(eq(moreProject.projectId, id));

    if (rt.length === 0) {
      return NextResponse.json({ error: 'moreProject not found' }, { status: 404 });
    }

    return NextResponse.json(rt);
  } catch (error) {
    console.error('Error fetching moreProject:', error);
    return NextResponse.json(
      { error: 'Internal Server Error' },
      { status: 500 }
    );
  }
};
