From f5ecba9c1e78610ab4aa14c91db6777122b73167 Mon Sep 17 00:00:00 2001 From: pi3c Date: Sun, 31 Mar 2024 01:36:57 +0300 Subject: [PATCH] Add Allusers view --- api/app_builder/routers.py | 3 ++- api/application/contracts/user/__init__.py | 3 +++ api/application/contracts/user/user_response.py | 7 +++++++ api/presentation/routers/__init__.py | 6 +++++- api/presentation/routers/user.py | 10 ++++++++++ 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 api/application/contracts/user/__init__.py create mode 100644 api/application/contracts/user/user_response.py create mode 100644 api/presentation/routers/user.py diff --git a/api/app_builder/routers.py b/api/app_builder/routers.py index f537b5c..67e77d2 100644 --- a/api/app_builder/routers.py +++ b/api/app_builder/routers.py @@ -1,7 +1,8 @@ from fastapi import FastAPI -from api.presentation.routers import healthcheck_router +from api.presentation.routers import healthcheck_router, user_router def init_routers(app: FastAPI) -> None: + app.include_router(user_router) app.include_router(healthcheck_router) diff --git a/api/application/contracts/user/__init__.py b/api/application/contracts/user/__init__.py new file mode 100644 index 0000000..27ba57a --- /dev/null +++ b/api/application/contracts/user/__init__.py @@ -0,0 +1,3 @@ +from .user_response import UserResponse + +__all__ = ("UserResponse",) diff --git a/api/application/contracts/user/user_response.py b/api/application/contracts/user/user_response.py new file mode 100644 index 0000000..110a868 --- /dev/null +++ b/api/application/contracts/user/user_response.py @@ -0,0 +1,7 @@ +from dataclasses import dataclass + + +@dataclass(frozen=True) +class UserResponse: + name: str + email: str diff --git a/api/presentation/routers/__init__.py b/api/presentation/routers/__init__.py index e568ca9..fff026a 100644 --- a/api/presentation/routers/__init__.py +++ b/api/presentation/routers/__init__.py @@ -1,3 +1,7 @@ from .ping import healthcheck_router +from .user import user_router -__all__ = ("healthcheck_router",) +__all__ = ( + "healthcheck_router", + "user_router", +) diff --git a/api/presentation/routers/user.py b/api/presentation/routers/user.py new file mode 100644 index 0000000..ad4a59e --- /dev/null +++ b/api/presentation/routers/user.py @@ -0,0 +1,10 @@ +from fastapi import APIRouter + +from api.application.contracts.user import UserResponse + +user_router = APIRouter(prefix="/users", tags=["Users"]) + + +@user_router.get("/") +async def get_all_users() -> list[UserResponse]: + return []