Files
expenses/server/src/routes.rs
T

39 lines
1.1 KiB
Rust

use axum::{http::StatusCode, routing::get};
use crate::error::AppError;
mod accounts;
mod auth_passkey;
mod auth_token;
mod dtos;
pub mod extractors;
mod scheduled_transactions;
mod transactions;
mod user_app_secrets;
mod user_apps;
mod users;
pub fn create_router(pool: sqlx::PgPool) -> axum::Router {
let api = axum::Router::new()
.nest("/auth/passkey", auth_passkey::create_router())
.nest("/auth/token", auth_token::create_router())
.nest("/accounts", accounts::create_router())
.nest(
"/scheduled-transactions",
scheduled_transactions::create_router(),
)
.nest("/transactions", transactions::create_router())
.nest("/users", users::create_router())
.nest("/users/{user_id}/apps", user_apps::create_router())
.nest(
"/users/{user_id}/apps/{app_id}/secrets",
user_app_secrets::create_router(),
);
axum::Router::new()
.nest("/api", api)
.route("/health", get(async || StatusCode::NO_CONTENT))
.fallback(async || AppError::NotFound)
.with_state(pool)
}