Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/app/interface/http/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@
from app.interface.http.controller.system import SystemController
from app.interface.http.lifespan import lifespan
from app.interface.http.middleware import RequestLoggingMiddleware
from app.interface.http.router import api_v1_router
from app.interface.http.util import (
create_exception_handlers,
get_all_application_error_mappings,
get_all_dependencies,
get_all_domain_error_mappings,
)
from app.module.identity.interface.http.controller.auth import AuthController
from app.module.identity.interface.http.controller.user import UserController
from app.module.parcel.interface.http.controller.parcel import ParcelController


def create_asgi_application() -> Litestar:
Expand All @@ -32,9 +30,7 @@ def create_asgi_application() -> Litestar:
app = Litestar(
route_handlers=[
SystemController,
AuthController,
UserController,
ParcelController,
api_v1_router,
],
dependencies=get_all_dependencies(),
openapi_config=OpenAPIConfig(
Expand Down
2 changes: 1 addition & 1 deletion src/app/interface/http/controller/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class SystemController(Controller):
"""System management endpoints."""

path = "api/v1/system"
path = "/system"
tags = ("system",)

@get(
Expand Down
22 changes: 22 additions & 0 deletions src/app/interface/http/router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""API v1 router.

Groups all module routers under the ``/api/v1`` prefix.
"""

from __future__ import annotations

from litestar import Router

from app.module.identity.interface.http.router import identity_router
from app.module.parcel.interface.http.router import parcel_router


api_v1_router = Router(
path="/api/v1",
route_handlers=[
identity_router,
parcel_router,
],
)

__all__ = ("api_v1_router",)
2 changes: 1 addition & 1 deletion src/app/module/identity/interface/http/controller/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
class AuthController(Controller):
"""Authentication and user management endpoints."""

path = "/api/v1/auth"
path = "/auth"
tags = ("auth",)

@post(
Expand All @@ -40,7 +40,7 @@
status_code=HTTP_201_CREATED,
description="Register a new user.",
)
async def register(

Check failure on line 43 in src/app/module/identity/interface/http/controller/auth.py

View workflow job for this annotation

GitHub Actions / Lint checks

ruff (no-self-use)

src/app/module/identity/interface/http/controller/auth.py:43:15: no-self-use: Method `register` could be a function, class method, or static method help: Consider adding `@typing.override` if this method overrides a method from a superclass
self,
data: RegisterRequest,
register_user_use_case: NamedDependency[RegisterUserUseCase],
Expand Down Expand Up @@ -75,7 +75,7 @@
status_code=HTTP_200_OK,
description="Authenticate a user and return JWT tokens.",
)
async def login(

Check failure on line 78 in src/app/module/identity/interface/http/controller/auth.py

View workflow job for this annotation

GitHub Actions / Lint checks

ruff (no-self-use)

src/app/module/identity/interface/http/controller/auth.py:78:15: no-self-use: Method `login` could be a function, class method, or static method help: Consider adding `@typing.override` if this method overrides a method from a superclass
self,
data: LoginRequest,
authenticate_user_use_case: NamedDependency[AuthenticateUserUseCase],
Expand Down Expand Up @@ -133,7 +133,7 @@
status_code=HTTP_200_OK,
description="Refresh access token using a refresh token.",
)
async def refresh(

Check failure on line 136 in src/app/module/identity/interface/http/controller/auth.py

View workflow job for this annotation

GitHub Actions / Lint checks

ruff (no-self-use)

src/app/module/identity/interface/http/controller/auth.py:136:15: no-self-use: Method `refresh` could be a function, class method, or static method help: Consider adding `@typing.override` if this method overrides a method from a superclass
self,
refresh_token_use_case: NamedDependency[RefreshTokenUseCase],
refresh_token: Annotated[str, CookieParameter(name="refresh_token", required=True)],
Expand Down
2 changes: 1 addition & 1 deletion src/app/module/identity/interface/http/controller/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class UserController(Controller):
"""User profile endpoints."""

path = "/api/v1/users"
path = "/users"
tags = ("users",)
guards = [require_authorization] # noqa: RUF012

Expand All @@ -24,7 +24,7 @@
status_code=HTTP_200_OK,
description="Get the profile of the currently authenticated user.",
)
async def get_profile(

Check failure on line 27 in src/app/module/identity/interface/http/controller/user.py

View workflow job for this annotation

GitHub Actions / Lint checks

ruff (no-self-use)

src/app/module/identity/interface/http/controller/user.py:27:15: no-self-use: Method `get_profile` could be a function, class method, or static method help: Consider adding `@typing.override` if this method overrides a method from a superclass
self,
get_user_use_case: NamedDependency[GetUserUseCase],
current_user: CurrentUser,
Expand Down
19 changes: 19 additions & 0 deletions src/app/module/identity/interface/http/router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Identity module HTTP router."""

from __future__ import annotations

from litestar import Router

from app.module.identity.interface.http.controller.auth import AuthController
from app.module.identity.interface.http.controller.user import UserController


identity_router = Router(
path="/identity",
route_handlers=[
AuthController,
UserController,
],
)

__all__ = ("identity_router",)
2 changes: 1 addition & 1 deletion src/app/module/parcel/interface/http/controller/parcel.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
class ParcelController(Controller):
"""Parcel management endpoints."""

path = "/api/v1/parcels"
path = "/"
tags = ("parcels",)
guards = [require_authorization] # noqa: RUF012

Expand All @@ -39,7 +39,7 @@
status_code=HTTP_201_CREATED,
description="Create a new parcel.",
)
async def create_parcel(

Check failure on line 42 in src/app/module/parcel/interface/http/controller/parcel.py

View workflow job for this annotation

GitHub Actions / Lint checks

ruff (no-self-use)

src/app/module/parcel/interface/http/controller/parcel.py:42:15: no-self-use: Method `create_parcel` could be a function, class method, or static method help: Consider adding `@typing.override` if this method overrides a method from a superclass
self,
data: CreateParcelRequest,
create_parcel_use_case: NamedDependency[CreateParcelUseCase],
Expand Down Expand Up @@ -82,7 +82,7 @@
status_code=HTTP_200_OK,
description="List all parcels owned by the current user.",
)
async def list_user_parcels(

Check failure on line 85 in src/app/module/parcel/interface/http/controller/parcel.py

View workflow job for this annotation

GitHub Actions / Lint checks

ruff (no-self-use)

src/app/module/parcel/interface/http/controller/parcel.py:85:15: no-self-use: Method `list_user_parcels` could be a function, class method, or static method help: Consider adding `@typing.override` if this method overrides a method from a superclass
self,
list_user_parcels_use_case: NamedDependency[ListUserParcelsUseCase],
current_user: CurrentUser,
Expand Down
17 changes: 17 additions & 0 deletions src/app/module/parcel/interface/http/router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Parcel module HTTP router."""

from __future__ import annotations

from litestar import Router

from app.module.parcel.interface.http.controller.parcel import ParcelController


parcel_router = Router(
path="/parcels",
route_handlers=[
ParcelController,
],
)

__all__ = ("parcel_router",)
Loading