2026-07-09 20:10:10 +00:00
|
|
|
import logging
|
|
|
|
|
from collections.abc import AsyncIterator
|
|
|
|
|
from contextlib import asynccontextmanager
|
|
|
|
|
|
2026-07-09 18:31:29 +00:00
|
|
|
from fastapi import FastAPI
|
|
|
|
|
|
|
|
|
|
from app.api.routes import cities, health, nearby, places
|
|
|
|
|
from app.config import settings
|
2026-07-09 20:10:10 +00:00
|
|
|
from app.core.logging import configure_logging, log_requests
|
|
|
|
|
|
|
|
|
|
configure_logging(level=getattr(logging, settings.log_level.upper(), logging.INFO))
|
|
|
|
|
logger = logging.getLogger("guidecity")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@asynccontextmanager
|
|
|
|
|
async def lifespan(_app: FastAPI) -> AsyncIterator[None]:
|
|
|
|
|
logger.info("guideCity API startup complete (log_level=%s)", settings.log_level)
|
|
|
|
|
yield
|
|
|
|
|
logger.info("guideCity API shutting down")
|
|
|
|
|
|
2026-07-09 18:31:29 +00:00
|
|
|
|
2026-07-09 20:10:10 +00:00
|
|
|
app = FastAPI(title="guideCity API", version="0.1.0", lifespan=lifespan)
|
|
|
|
|
app.middleware("http")(log_requests)
|
2026-07-09 18:31:29 +00:00
|
|
|
|
|
|
|
|
app.include_router(health.router, prefix=settings.api_v1_prefix)
|
|
|
|
|
app.include_router(cities.router, prefix=settings.api_v1_prefix)
|
|
|
|
|
app.include_router(places.router, prefix=settings.api_v1_prefix)
|
|
|
|
|
app.include_router(nearby.router, prefix=settings.api_v1_prefix)
|