-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdependencies.py
More file actions
55 lines (41 loc) · 1.43 KB
/
Copy pathdependencies.py
File metadata and controls
55 lines (41 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from fastapi import Depends
from core.security.utils.hashing import hash_password
from core.security.utils.token_utils import generate_token, hash_token
from infrastructure.sqlalchemy.AsyncSession import AsyncSessionLocal
from .controllers import UserRegistrationController
from .repository import ProfileRepository, UserRepository
from .selectors import UserSelector
from .service import ProfileService, UserService
def get_user_repo():
return UserRepository()
def get_profile_repo():
return ProfileRepository()
def get_user_service(user_repo=Depends(get_user_repo)):
return UserService(
user_repo=user_repo,
token_generator=generate_token,
hasher_password=hash_password,
hasher_token=hash_token,
)
def get_profile_service(profile_repo=Depends(get_profile_repo)):
return ProfileService(
profile_repo=profile_repo,
)
def get_registration_service(
user_service: UserService = Depends(get_user_service),
profile_service: ProfileService = Depends(get_profile_service),
):
return UserRegistrationController(
user_service=user_service,
profile_service=profile_service,
session_factory=AsyncSessionLocal,
)
def get_user_selector(
user_repo=Depends(get_user_repo),
profile_repo=Depends(get_profile_repo),
):
return UserSelector(
user_repo=user_repo,
profile_repo=profile_repo,
session_factory=AsyncSessionLocal,
)