The hackathon_auth_middleware requires Arc<PgPool> from Extension, but was applied as the outermost layer (running before Extension(pool) was injected). Swapped layer order so pool Extension is outermost, making it available when the auth middleware runs. Fixes 500 errors on all /v1/hackathon/* authenticated endpoints. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
32 lines
1008 B
Rust
32 lines
1008 B
Rust
use super::handlers::*;
|
|
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;
|
|
use axum::{
|
|
Extension, Router,
|
|
middleware::from_fn,
|
|
routing::{get, post},
|
|
};
|
|
use sqlx::PgPool;
|
|
use std::sync::Arc;
|
|
|
|
pub fn build_invitation_routes(pool: Arc<PgPool>) -> Router {
|
|
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(
|
|
"/invitations/{invitation_id}/respond",
|
|
post(respond_to_invitation_handler),
|
|
)
|
|
.route(
|
|
"/invitations/teams/{team_id}/invite",
|
|
post(invite_team_member_handler),
|
|
)
|
|
.layer(Extension(service))
|
|
.layer(from_fn(hackathon_auth_middleware))
|
|
.layer(Extension(pool))
|
|
}
|