2025-09-27 13:01:08 +07:00
|
|
|
use axum::Router;
|
|
|
|
|
|
|
|
|
|
pub mod hackathon;
|
2025-10-27 19:53:05 +07:00
|
|
|
pub mod notifications;
|
2025-10-27 19:23:29 +07:00
|
|
|
pub mod registrations;
|
2025-09-27 13:01:08 +07:00
|
|
|
|
|
|
|
|
// Export the router function from hackathon module
|
|
|
|
|
pub use hackathon::hackathon_router;
|
2025-10-27 19:53:05 +07:00
|
|
|
pub use notifications::notifications_router;
|
2025-10-27 19:23:29 +07:00
|
|
|
pub use registrations::registrations_router;
|
2025-09-27 13:01:08 +07:00
|
|
|
|
|
|
|
|
// Main route constructor
|
|
|
|
|
pub fn hackathon_protected_routes() -> Router {
|
2025-10-11 10:58:51 +07:00
|
|
|
// Protected routes include the main hackathon router (create/update/delete) and
|
|
|
|
|
// a protected route for updating submission status.
|
2025-10-13 10:57:53 +07:00
|
|
|
use hackathon::hackathon_controller::{update_submission_status, get_admin_hackathon_results};
|
2025-10-11 10:58:51 +07:00
|
|
|
Router::new()
|
|
|
|
|
.nest("/hackathons", hackathon_router())
|
|
|
|
|
.route("/hackathons/submissions/{id}/status", axum::routing::patch(update_submission_status))
|
2025-10-13 10:57:53 +07:00
|
|
|
.route("/hackathons/{hackathon_id}/admin/results", axum::routing::get(get_admin_hackathon_results))
|
2025-10-27 19:23:29 +07:00
|
|
|
.merge(registrations_router())
|
2025-10-27 19:53:05 +07:00
|
|
|
.merge(notifications_router())
|
2025-10-05 20:23:34 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Public routes for hackathons (only listing and retrieving)
|
|
|
|
|
pub fn hackathon_public_routes() -> Router {
|
2025-10-13 10:57:53 +07:00
|
|
|
use hackathon::hackathon_controller::{
|
|
|
|
|
list_hackathons,
|
|
|
|
|
get_hackathon,
|
|
|
|
|
search_hackathons,
|
|
|
|
|
get_user_hackathon_submissions,
|
|
|
|
|
get_public_hackathon_results,
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-05 20:23:34 +07:00
|
|
|
Router::new()
|
|
|
|
|
.nest("/hackathons", Router::new()
|
|
|
|
|
.route("/", axum::routing::get(list_hackathons))
|
|
|
|
|
.route("/{id}", axum::routing::get(get_hackathon))
|
2025-10-13 10:57:53 +07:00
|
|
|
.route("/{id}/results", axum::routing::get(get_public_hackathon_results))
|
2025-10-11 10:58:51 +07:00
|
|
|
.route("/search", axum::routing::post(search_hackathons))
|
2025-10-05 20:23:34 +07:00
|
|
|
)
|
2025-10-11 10:58:51 +07:00
|
|
|
.route("/users/{user_id}/hackathon-submissions", axum::routing::get(get_user_hackathon_submissions))
|
2025-09-27 13:01:08 +07:00
|
|
|
}
|