2026-04-02 22:29:08 +07:00
|
|
|
use super::handlers::*;
|
2026-04-02 15:15:00 +07:00
|
|
|
use crate::invitations::application::invitation_service::InvitationServiceImpl;
|
|
|
|
|
use crate::invitations::domain::service::InvitationService;
|
|
|
|
|
use crate::invitations::infrastructure::persistence::PostgresInvitationRepository;
|
|
|
|
|
use crate::middleware::hackathon_auth::hackathon_auth_middleware;
|
2026-04-02 22:29:08 +07:00
|
|
|
use axum::{
|
|
|
|
|
Extension, Router,
|
|
|
|
|
middleware::from_fn,
|
|
|
|
|
routing::{get, post},
|
|
|
|
|
};
|
|
|
|
|
use sqlx::PgPool;
|
|
|
|
|
use std::sync::Arc;
|
2026-04-02 15:15:00 +07:00
|
|
|
|
2026-04-02 16:33:02 +07:00
|
|
|
pub fn build_invitation_routes(pool: Arc<PgPool>) -> Router {
|
2026-04-02 22:29:08 +07:00
|
|
|
let service: Arc<dyn InvitationService> = Arc::new(InvitationServiceImpl::new(
|
|
|
|
|
Arc::new(PostgresInvitationRepository::new(pool.clone())),
|
|
|
|
|
));
|
|
|
|
|
Router::new()
|
|
|
|
|
.route("/invitations/my", get(get_my_invitations_handler))
|
|
|
|
|
.route(
|
2026-04-02 23:56:59 +07:00
|
|
|
"/invitations/{invitation_id}/respond",
|
2026-04-02 22:29:08 +07:00
|
|
|
post(respond_to_invitation_handler),
|
|
|
|
|
)
|
|
|
|
|
.route(
|
2026-04-02 23:56:59 +07:00
|
|
|
"/invitations/teams/{team_id}/invite",
|
2026-04-02 22:29:08 +07:00
|
|
|
post(invite_team_member_handler),
|
|
|
|
|
)
|
|
|
|
|
.layer(Extension(service))
|
|
|
|
|
.layer(Extension(pool))
|
|
|
|
|
.layer(from_fn(hackathon_auth_middleware))
|
2026-04-02 15:15:00 +07:00
|
|
|
}
|