Files
portfolio-hub/app/main.py
T

36 lines
950 B
Python

"""FastAPI application entrypoint."""
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api.health import router as health_router
from app.api.portfolios import router as portfolio_router
from app.core.config import get_settings
from app.core.errors import register_exception_handlers
def create_app() -> FastAPI:
settings = get_settings()
app = FastAPI(
title=settings.app_name,
version=settings.app_version,
docs_url="/docs",
redoc_url="/redoc",
)
app.add_middleware(
CORSMiddleware,
allow_origins=settings.allowed_origins,
allow_credentials=True,
allow_methods=["GET", "POST", "PATCH", "DELETE", "OPTIONS"],
allow_headers=["Authorization", "Content-Type"],
)
app.include_router(health_router)
app.include_router(portfolio_router)
register_exception_handlers(app)
return app
app = create_app()