Mobile support to come.
use std::sync::Arc;
use axum::extract::FromRef;
use sqlx::PgPool;
use gitdot_core::client::{Git2Client, GitHttpClientImpl};
use gitdot_core::repository::{
CommitRepositoryImpl, OAuthRepositoryImpl, OrganizationRepositoryImpl, QuestionRepositoryImpl,
RepositoryRepositoryImpl, UserRepositoryImpl,
};
use gitdot_core::service::{
AuthorizationService, AuthorizationServiceImpl, CommitService, CommitServiceImpl,
GitHttpService, GitHttpServiceImpl, OAuthService, OAuthServiceImpl, OrganizationService,
OrganizationServiceImpl, QuestionService, QuestionServiceImpl, RepositoryService,
RepositoryServiceImpl, UserService, UserServiceImpl,
};
use super::Settings;
#[derive(FromRef, Clone)]
pub struct AppState {
pub settings: Arc<Settings>,
pub auth_service: Arc<dyn AuthorizationService>,
pub user_service: Arc<dyn UserService>,
pub org_service: Arc<dyn OrganizationService>,
pub repo_service: Arc<dyn RepositoryService>,
pub question_service: Arc<dyn QuestionService>,
pub commit_service: Arc<dyn CommitService>,
pub git_http_service: Arc<dyn GitHttpService>,
pub oauth_service: Arc<dyn OAuthService>,
}
impl AppState {
pub fn new(settings: Arc<Settings>, pool: PgPool) -> Self {
let git_client = Git2Client::new(settings.git_project_root.clone());
let git_http_client = GitHttpClientImpl::new(settings.git_project_root.clone());
let org_repo = OrganizationRepositoryImpl::new(pool.clone());
let repo_repo = RepositoryRepositoryImpl::new(pool.clone());
let user_repo = UserRepositoryImpl::new(pool.clone());
let question_repo = QuestionRepositoryImpl::new(pool.clone());
let commit_repo = CommitRepositoryImpl::new(pool.clone());
let oauth_repo = OAuthRepositoryImpl::new(pool.clone());
let auth_service = Arc::new(AuthorizationServiceImpl::new(
org_repo.clone(),
repo_repo.clone(),
question_repo.clone(),
user_repo.clone(),
));
let user_service = Arc::new(UserServiceImpl::new(user_repo.clone(), repo_repo.clone()));
let org_service = Arc::new(OrganizationServiceImpl::new(
org_repo.clone(),
user_repo.clone(),
repo_repo.clone(),
));
let repo_service = Arc::new(RepositoryServiceImpl::new(
git_client.clone(),
org_repo.clone(),
repo_repo.clone(),
user_repo.clone(),
));
let question_service = Arc::new(QuestionServiceImpl::new(
question_repo.clone(),
repo_repo.clone(),
));
let commit_service = Arc::new(CommitServiceImpl::new(commit_repo.clone()));
let git_http_service = Arc::new(GitHttpServiceImpl::new(git_http_client.clone()));
let oauth_service = Arc::new(OAuthServiceImpl::new(oauth_repo.clone(), user_repo.clone()));
Self {
settings,
auth_service,
user_service,
org_service,
repo_service,
question_service,
commit_service,
git_http_service,
oauth_service,
}
}
}
wired up commit service in backend
mikkel•3e9fcb22d ago
replaced create_user api with validate_name api
mikkel•0e0bf523d ago
implemented create user endpoint
mikkel•5b3ad656d ago
updated commits api to return gitdot user info if exist
mikkel•3060c5a6d ago
updated poll token to return user name and email as well
mikkel•cc923f18d ago
wired up oauth in backend
mikkel•13cdd308d ago
implemented get user and list user repos apis
mike•7ce056912d ago
implemented get org repositories api
mike•30938bb12d ago
added auth for repo creation
mike•cf3beb612d ago
rolled back to standard question apis
mike•ef0cc8213d ago
added auth for update apis
mike•910376914d ago
wired up question apis
mike•4ea4d4014d ago
put repo apis behind authorization
mike•3736fbc15d ago
renamed GitHttpBackendService -> GitHttpService
mike•c1acceb16d ago
refactoring git_http in progress
mike•febbd1116d ago
refactored repository core
mike•ca1236717d ago
migrated git http endpoints to new arch
mike•fbc763320d ago
migrated create_repository to new design
mike•f5802ef20d ago
implemented optional extractor to extract auth user from jwt token in request header
mike•988f77f22d ago
updated create_organization to check for duplicate name
mike•6b239d423d ago
added org server in app state
mike•e95ce8623d ago
updated both app state and settings to derive from Debug
mike•333649a1mo ago
created gitdot lib
mike•d2ec2131mo ago