27 lines
850 B
Python
27 lines
850 B
Python
"""Company endpoints (section 17)."""
|
|||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from fastapi import APIRouter, Depends
|
||
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||
|
|
|
||
|
|
from app.api.deps import not_found
|
||
|
|
from app.core.database import get_db
|
||
|
|
from app.core.security import enforce_rate_limit
|
||
|
|
from app.schemas.company import CompanyDetailOut
|
||
|
|
from app.services import company_service
|
||
|
|
|
||
|
|
router = APIRouter(
|
||
|
|
prefix="/companies", tags=["companies"], dependencies=[Depends(enforce_rate_limit)]
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
@router.get("/{aurora_id}", response_model=CompanyDetailOut)
|
||
|
|
async def get_company(
|
||
|
|
aurora_id: str, session: AsyncSession = Depends(get_db)
|
||
|
|
) -> CompanyDetailOut:
|
||
|
|
try:
|
||
|
|
return await company_service.get_company_detail(session, aurora_id)
|
||
|
|
except company_service.CompanyNotFoundError as exc:
|
||
|
|
raise not_found("company", aurora_id) from exc
|