Skip to content

Commit a5edc25

Browse files
committed
refactor(user): use PostgresUserRepository inside router instead of in memory
1 parent 5006d91 commit a5edc25

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/social/user/infra/router/signup_user_router.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
from fastapi.responses import JSONResponse
33

44
from src.shared.infra.HttpResponse import HttpResponse
5+
6+
from src.shared.infra.persistence.sqlalchemy.session_maker import SessionMaker
7+
from src.shared.infra.settings import Settings
58
from src.social.user.application.signup.user_signup import UserSignup
69
from src.social.user.application.signup.user_signup_command import UserSignupCommand
7-
from src.social.user.infra.in_memory_user_repository import InMemoryUserRepository
10+
from src.social.user.infra.persistence.postgres_user_repository import (
11+
PostgresUserRepository,
12+
)
813
from src.social.user.infra.router.user_sign_up_request import UserSignupRequest
914

1015
router = APIRouter(prefix="/users", tags=["Users"])
@@ -18,7 +23,9 @@ async def signup_user(user_id: str, request: UserSignupRequest) -> JSONResponse:
1823
username=request.username,
1924
email=request.email,
2025
)
21-
user_signup = UserSignup(InMemoryUserRepository())
26+
session_maker = SessionMaker(Settings())
27+
repository = PostgresUserRepository(session_maker=session_maker)
28+
user_signup = UserSignup(repository)
2229

2330
await user_signup(command)
2431

0 commit comments

Comments
 (0)