Coverage for app/main.py: 94%
16 statements
« prev ^ index » next coverage.py v7.16.1, created at 2026-10-26 10:48 +0000
« prev ^ index » next coverage.py v7.16.1, created at 2026-10-26 10:48 +0000
1from pathlib import Path
3import sentry_sdk
4from fastapi import FastAPI
5from fastapi.routing import APIRoute
6from starlette.middleware.cors import CORSMiddleware
8from app.api.main import api_router
9from app.core.config import settings
11FRONTEND_DIR = Path(__file__).parent / "frontend"
14def custom_generate_unique_id(route: APIRoute) -> str:
15 return f"{route.tags[0]}-{route.name}" 1abc
18if settings.SENTRY_DSN and settings.FASTAPI_ENV != "development":
19 sentry_sdk.init(dsn=str(settings.SENTRY_DSN), enable_tracing=True)
21app = FastAPI(
22 title=settings.PROJECT_NAME,
23 openapi_url=f"{settings.API_V1_STR}/openapi.json",
24 generate_unique_id_function=custom_generate_unique_id,
25)
27app.add_middleware(
28 CORSMiddleware,
29 allow_origins=[settings.FRONTEND_HOST],
30 allow_credentials=True,
31 allow_methods=["*"],
32 allow_headers=["*"],
33)
35app.include_router(api_router, prefix=settings.API_V1_STR)
36app.frontend("/", directory=FRONTEND_DIR)