40 lines
1.1 KiB
Python
40 lines
1.1 KiB
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.api.strategy_sets import router as strategy_sets_router
|
|
from app.api.users import router as users_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)
|
|
app.include_router(strategy_sets_router)
|
|
app.include_router(users_router)
|
|
register_exception_handlers(app)
|
|
return app
|
|
|
|
|
|
app = create_app()
|