11use std:: sync:: Arc ;
22
3- use crate :: domain:: repositories:: { GithubIssueRepository , ProfileRepository , ProjectRepository } ;
3+ use crate :: domain:: repositories:: {
4+ DistributionRepository , GithubIssueRepository , ProfileRepository , ProjectRepository ,
5+ } ;
46use crate :: domain:: services:: auth_service:: AuthService ;
57use crate :: domain:: services:: github_service:: GithubService ;
68use crate :: infrastructure:: {
79 repositories:: {
10+ postgres_distribution_repository:: PostgresDistributionRepository ,
811 postgres_github_issue_repository:: PostgresGithubIssueRepository ,
912 postgres_project_repository:: PostgresProjectRepository , PostgresProfileRepository ,
1013 } ,
@@ -43,6 +46,7 @@ use super::handlers::{
4346 list_github_issues_handler,
4447 list_projects_handler,
4548 login_handler,
49+ register_distribution_handler,
4650 update_profile_handler,
4751 update_project_handler,
4852} ;
@@ -52,13 +56,15 @@ use super::middlewares::{admin_auth_layer, eth_auth_layer, test_auth_layer};
5256pub async fn create_app ( pool : sqlx:: PgPool ) -> Router {
5357 let profile_repository = Arc :: from ( PostgresProfileRepository :: new ( pool. clone ( ) ) ) ;
5458 let project_repository = Arc :: from ( PostgresProjectRepository :: new ( pool. clone ( ) ) ) ;
59+ let distribution_repository = Arc :: from ( PostgresDistributionRepository :: new ( pool. clone ( ) ) ) ;
5560 let github_issue_repository = Arc :: from ( PostgresGithubIssueRepository :: new ( pool) ) ;
5661 let auth_service = EthereumAddressVerificationService :: new ( profile_repository. clone ( ) ) ;
5762 let github_service: Arc < dyn GithubService > = Arc :: from ( RestGithubService :: new ( ) ) ;
5863
5964 let state: AppState = AppState {
6065 profile_repository,
6166 project_repository,
67+ distribution_repository,
6268 auth_service : Arc :: from ( auth_service) ,
6369 github_issue_repository,
6470 github_service,
@@ -76,6 +82,7 @@ pub async fn create_app(pool: sqlx::PgPool) -> Router {
7682 . route ( "/projects" , post ( create_project_handler) )
7783 . route ( "/projects/:id" , patch ( update_project_handler) )
7884 . route ( "/projects/:id" , delete ( delete_project_handler) )
85+ . route ( "/distributions" , post ( register_distribution_handler) )
7986 . with_state ( state. clone ( ) ) ;
8087
8188 let protected_with_auth = if std:: env:: var ( "TEST_MODE" ) . is_ok ( ) {
@@ -142,6 +149,7 @@ pub async fn create_app(pool: sqlx::PgPool) -> Router {
142149pub struct AppState {
143150 pub profile_repository : Arc < dyn ProfileRepository > ,
144151 pub project_repository : Arc < dyn ProjectRepository > ,
152+ pub distribution_repository : Arc < dyn DistributionRepository > ,
145153 pub auth_service : Arc < dyn AuthService > ,
146154 pub github_issue_repository : Arc < dyn GithubIssueRepository > ,
147155 pub github_service : Arc < dyn GithubService > ,
@@ -159,6 +167,7 @@ pub fn test_api(state: AppState) -> Router {
159167 . route ( "/projects" , post ( create_project_handler) )
160168 . route ( "/projects/:id" , patch ( update_project_handler) )
161169 . route ( "/projects/:id" , delete ( delete_project_handler) )
170+ . route ( "/distributions" , post ( register_distribution_handler) )
162171 . with_state ( state. clone ( ) )
163172 . layer ( from_fn ( test_auth_layer) ) ;
164173
0 commit comments