backend/src/api/v1/mod.rs
BAaboe c26ec49e05
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
ci/woodpecker/pr/build-and-publish Pipeline was successful
ci/woodpecker/pull_request_closed/build-and-publish Pipeline was successful
fix: cargo clippy --fix && cargo fmt
2025-07-22 18:50:17 +02:00

35 lines
924 B
Rust

//! `/api/v1` Contains version 1 of the api
use std::sync::Arc;
use axum::{Router, middleware::from_fn_with_state, routing::get};
use crate::{AppState, api::v1::auth::CurrentUser};
mod auth;
mod channels;
mod guilds;
mod invites;
mod me;
mod members;
mod stats;
mod users;
pub fn router(app_state: Arc<AppState>) -> Router<Arc<AppState>> {
let router_with_auth = Router::new()
.nest("/users", users::router())
.nest("/guilds", guilds::router())
.nest("/invites", invites::router())
.nest("/members", members::router())
.nest("/me", me::router())
.layer(from_fn_with_state(
app_state.clone(),
CurrentUser::check_auth_layer,
));
Router::new()
.route("/stats", get(stats::res))
.nest("/auth", auth::router(app_state.clone()))
.nest("/channels", channels::router(app_state))
.merge(router_with_auth)
}