Skip to content

Commit 781d3c8

Browse files
committed
ref(fastapi): group code by aggregates
1 parent b4d34bd commit 781d3c8

34 files changed

+98
-74
lines changed

src/tgdb/presentation/adapters/relation_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from tgdb.application.common.ports.relation_views import RelationViews
77
from tgdb.entities.numeration.number import Number
88
from tgdb.entities.relation.relation import Relation
9-
from tgdb.presentation.fastapi.schemas.relation.relation import (
9+
from tgdb.presentation.fastapi.relation.schemas.relation import (
1010
RelationListSchema,
1111
RelationSchema,
1212
)
File renamed without changes.

src/tgdb/presentation/fastapi/app.py renamed to src/tgdb/presentation/fastapi/common/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from dishka.integrations.fastapi import setup_dishka
66
from fastapi import APIRouter, FastAPI
77

8-
from tgdb.presentation.fastapi.tags import tags_metadata
8+
from tgdb.presentation.fastapi.common.tags import tags_metadata
99

1010

1111
type FastAPIAppRouters = Iterable[APIRouter]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from fastapi import FastAPI, Response, status
2+
from fastapi.responses import JSONResponse
3+
4+
from tgdb.application.common.ports.relations import NoRelationError
5+
from tgdb.presentation.fastapi.common.schemas.error import NoRelationSchema
6+
from tgdb.presentation.fastapi.horizon.error_handling import (
7+
add_horizon_error_handling,
8+
)
9+
10+
11+
def add_error_handling(app: FastAPI) -> None:
12+
add_common_error_handling(app)
13+
add_horizon_error_handling(app)
14+
15+
16+
def add_common_error_handling(app: FastAPI) -> None:
17+
@app.exception_handler(NoRelationError)
18+
def _(_: object) -> Response:
19+
schema = NoRelationSchema()
20+
21+
return JSONResponse(
22+
schema.model_dump(mode="json", by_alias=True),
23+
status_code=status.HTTP_404_NOT_FOUND,
24+
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from tgdb.presentation.fastapi.common.routes.healthcheck import (
2+
healthcheck_router,
3+
)
4+
from tgdb.presentation.fastapi.horizon.routers import horizon_routers
5+
from tgdb.presentation.fastapi.relation.routers import relation_routers
6+
7+
8+
_monitoring_routers = (
9+
healthcheck_router,
10+
)
11+
12+
13+
all_routers = (
14+
*_monitoring_routers,
15+
*horizon_routers,
16+
*relation_routers,
17+
)
File renamed without changes.

src/tgdb/presentation/fastapi/routes/healthcheck.py renamed to src/tgdb/presentation/fastapi/common/routes/healthcheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from fastapi import APIRouter, status
22
from fastapi.responses import Response
33

4-
from tgdb.presentation.fastapi.tags import Tag
4+
from tgdb.presentation.fastapi.common.tags import Tag
55

66

77
healthcheck_router = APIRouter()

src/tgdb/presentation/fastapi/schemas/horizon/__init__.py renamed to src/tgdb/presentation/fastapi/common/schemas/__init__.py

File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)