Move admin module into app module

This commit is contained in:
Matthew Gordon 2024-02-26 15:10:09 -04:00
parent 1fab78ff96
commit 841b16986b
3 changed files with 7 additions and 5 deletions

View File

@ -22,7 +22,7 @@ use {
serde::Deserialize,
};
use super::app::AppState;
use super::AppState;
pub fn routes<D: Database>() -> Router<AppState<D>> {
Router::new()

View File

@ -4,13 +4,17 @@ use {
axum::{routing::get, Router},
};
pub mod admin;
#[derive(Clone)]
pub struct AppState<D: Database> {
pub db: D,
}
pub fn routes<D: Database>() -> Router<AppState<D>> {
Router::new().route("/", get(root))
Router::new()
.route("/", get(root))
.nest("/admin", admin::routes())
}
#[derive(Template)]

View File

@ -4,7 +4,6 @@ use {
tracing::Level,
};
mod admin;
mod app;
mod authentication;
mod config;
@ -54,7 +53,6 @@ async fn locality_main() -> Result<(), Error> {
db_pool.migrate_to_current_version().await.unwrap();
let app = app::routes()
.nest("/admin", admin::routes())
.with_state(app::AppState { db: db_pool })
.nest_service("/static", ServeDir::new(&config.static_file_path))
.layer(TraceLayer::new_for_http());