import { getComplexBySlug } from '@/modules/complex/services/complex.service';
import type { AppContext } from '@/types/hono';

type ComplexSlugParams = { slug: string };

export async function getComplexBySlugHandler(c: AppContext) {
  const { slug } = c.req.valid('param' as never) as ComplexSlugParams;

  const complex = await getComplexBySlug(slug);

  if (!complex) {
    return c.json({ message: 'Complejo no encontrado.' }, 404);
  }

  return c.json(complex);
}
