"""User routes — thin handlers (≤50 lines), delegate to services."""

from fastapi import APIRouter

from {{ cookiecutter.project_name }}.schemas.user import UserResponse
from {{ cookiecutter.project_name }}.services.user_service import UserService

router = APIRouter()


@router.get("", response_model=list[UserResponse])
async def list_users() -> list[UserResponse]:
    """List users — thin handler, business logic lives in the service."""
    users = await UserService.get_users()
    return [UserResponse.model_validate(u) for u in users]


@router.get("/{user_id}", response_model=UserResponse)
async def get_user(user_id: int) -> UserResponse:
    """Get a single user by id — thin handler."""
    user = await UserService.get_user(user_id)
    return UserResponse.model_validate(user)