refactor: split large directories into coffee/auth/analytics subdirs
- Restructure domain/, repositories/, and routes/api/ into themed subdirectories: coffee/, auth/, analytics/ (and system/ for routes) - Convert super:: relative imports to crate:: absolute paths - Promote macro visibility from pub(super) to pub(crate) - Add pub use re-exports for backward-compatible import paths
This commit is contained in:
parent
0fd4214b6c
commit
edc0021792
60 changed files with 112 additions and 81 deletions
1
src/application/routes/api/analytics/mod.rs
Normal file
1
src/application/routes/api/analytics/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
pub(crate) mod stats;
|
||||
2
src/application/routes/api/auth/mod.rs
Normal file
2
src/application/routes/api/auth/mod.rs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
pub(crate) mod tokens;
|
||||
pub(crate) mod webauthn;
|
||||
|
|
@ -6,9 +6,9 @@ use chrono::{DateTime, Utc};
|
|||
use serde::Deserialize;
|
||||
use tracing::info;
|
||||
|
||||
use super::macros::{define_delete_handler, define_enriched_get_handler};
|
||||
use crate::application::auth::AuthenticatedUser;
|
||||
use crate::application::errors::{ApiError, AppError};
|
||||
use crate::application::routes::api::macros::{define_delete_handler, define_enriched_get_handler};
|
||||
use crate::application::routes::support::{
|
||||
FlexiblePayload, ListQuery, PayloadSource, is_datastar_request,
|
||||
};
|
||||
|
|
@ -6,9 +6,9 @@ use chrono::{DateTime, Utc};
|
|||
use serde::{Deserialize, Deserializer};
|
||||
use tracing::info;
|
||||
|
||||
use super::macros::{define_delete_handler, define_enriched_get_handler};
|
||||
use crate::application::auth::AuthenticatedUser;
|
||||
use crate::application::errors::{ApiError, AppError};
|
||||
use crate::application::routes::api::macros::{define_delete_handler, define_enriched_get_handler};
|
||||
use crate::application::routes::support::{
|
||||
FlexiblePayload, ListQuery, PayloadSource, is_datastar_request,
|
||||
};
|
||||
|
|
@ -4,9 +4,11 @@ use axum::http::{HeaderMap, StatusCode};
|
|||
use axum::response::{IntoResponse, Redirect, Response};
|
||||
use serde::Deserialize;
|
||||
|
||||
use super::macros::{define_delete_handler, define_get_handler, define_list_fragment_renderer};
|
||||
use crate::application::auth::AuthenticatedUser;
|
||||
use crate::application::errors::{ApiError, AppError};
|
||||
use crate::application::routes::api::macros::{
|
||||
define_delete_handler, define_get_handler, define_list_fragment_renderer,
|
||||
};
|
||||
use crate::application::routes::support::{
|
||||
FlexiblePayload, ListQuery, PayloadSource, is_datastar_request,
|
||||
};
|
||||
|
|
@ -3,11 +3,11 @@ use axum::extract::{Query, State};
|
|||
use axum::http::{HeaderMap, StatusCode};
|
||||
use axum::response::{IntoResponse, Redirect, Response};
|
||||
|
||||
use super::macros::{
|
||||
define_delete_handler, define_enriched_get_handler, define_list_fragment_renderer,
|
||||
};
|
||||
use crate::application::auth::AuthenticatedUser;
|
||||
use crate::application::errors::{ApiError, AppError};
|
||||
use crate::application::routes::api::macros::{
|
||||
define_delete_handler, define_enriched_get_handler, define_list_fragment_renderer,
|
||||
};
|
||||
use crate::application::routes::support::{
|
||||
FlexiblePayload, ListQuery, PayloadSource, is_datastar_request,
|
||||
};
|
||||
|
|
@ -8,9 +8,11 @@ use chrono::{DateTime, Utc};
|
|||
use serde::Deserialize;
|
||||
use tracing::info;
|
||||
|
||||
use super::macros::{define_delete_handler, define_get_handler, define_list_fragment_renderer};
|
||||
use crate::application::auth::AuthenticatedUser;
|
||||
use crate::application::errors::{ApiError, AppError};
|
||||
use crate::application::routes::api::macros::{
|
||||
define_delete_handler, define_get_handler, define_list_fragment_renderer,
|
||||
};
|
||||
use crate::application::routes::support::{
|
||||
FlexiblePayload, ListQuery, PayloadSource, is_datastar_request,
|
||||
};
|
||||
9
src/application/routes/api/coffee/mod.rs
Normal file
9
src/application/routes/api/coffee/mod.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
pub(crate) mod bags;
|
||||
pub(crate) mod brews;
|
||||
pub(crate) mod cafes;
|
||||
pub(crate) mod checkin;
|
||||
pub(crate) mod cups;
|
||||
pub(crate) mod gear;
|
||||
pub(crate) mod roasters;
|
||||
pub(crate) mod roasts;
|
||||
pub(crate) mod scan;
|
||||
|
|
@ -3,9 +3,11 @@ use axum::extract::{Path, Query, State};
|
|||
use axum::http::{HeaderMap, StatusCode};
|
||||
use axum::response::{IntoResponse, Redirect, Response};
|
||||
|
||||
use super::macros::{define_delete_handler, define_get_handler, define_list_fragment_renderer};
|
||||
use crate::application::auth::AuthenticatedUser;
|
||||
use crate::application::errors::{ApiError, AppError};
|
||||
use crate::application::routes::api::macros::{
|
||||
define_delete_handler, define_get_handler, define_list_fragment_renderer,
|
||||
};
|
||||
use crate::application::routes::support::{
|
||||
FlexiblePayload, ListQuery, PayloadSource, is_datastar_request,
|
||||
};
|
||||
|
|
@ -5,11 +5,11 @@ use axum::response::{IntoResponse, Redirect, Response};
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::Deserialize;
|
||||
|
||||
use super::macros::{
|
||||
define_delete_handler, define_enriched_get_handler, define_list_fragment_renderer,
|
||||
};
|
||||
use crate::application::auth::AuthenticatedUser;
|
||||
use crate::application::errors::{ApiError, AppError};
|
||||
use crate::application::routes::api::macros::{
|
||||
define_delete_handler, define_enriched_get_handler, define_list_fragment_renderer,
|
||||
};
|
||||
use crate::application::routes::support::{
|
||||
FlexiblePayload, ListQuery, PayloadSource, is_datastar_request,
|
||||
};
|
||||
|
|
@ -5,9 +5,9 @@ use axum::response::{IntoResponse, Response};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use tracing::info;
|
||||
|
||||
use super::roasts::TastingNotesInput;
|
||||
use crate::application::auth::AuthenticatedUser;
|
||||
use crate::application::errors::{ApiError, AppError};
|
||||
use crate::application::routes::api::roasts::TastingNotesInput;
|
||||
use crate::application::routes::support::{FlexiblePayload, is_datastar_request};
|
||||
use crate::application::state::AppState;
|
||||
use crate::domain::bags::NewBag;
|
||||
|
|
@ -169,7 +169,7 @@ macro_rules! define_list_fragment_renderer {
|
|||
};
|
||||
}
|
||||
|
||||
pub(super) use define_delete_handler;
|
||||
pub(super) use define_enriched_get_handler;
|
||||
pub(super) use define_get_handler;
|
||||
pub(super) use define_list_fragment_renderer;
|
||||
pub(crate) use define_delete_handler;
|
||||
pub(crate) use define_enriched_get_handler;
|
||||
pub(crate) use define_get_handler;
|
||||
pub(crate) use define_list_fragment_renderer;
|
||||
|
|
|
|||
|
|
@ -1,18 +1,14 @@
|
|||
pub(crate) mod admin;
|
||||
pub(crate) mod backup;
|
||||
pub(crate) mod bags;
|
||||
pub(crate) mod brews;
|
||||
pub(crate) mod cafes;
|
||||
pub(crate) mod checkin;
|
||||
pub(crate) mod cups;
|
||||
pub(crate) mod gear;
|
||||
mod macros;
|
||||
pub(crate) mod roasters;
|
||||
pub(crate) mod roasts;
|
||||
pub(crate) mod scan;
|
||||
pub(crate) mod stats;
|
||||
pub(crate) mod tokens;
|
||||
pub(crate) mod webauthn;
|
||||
pub(crate) mod analytics;
|
||||
pub(crate) mod auth;
|
||||
pub(crate) mod coffee;
|
||||
pub(crate) mod macros;
|
||||
pub(crate) mod system;
|
||||
|
||||
// Re-exports for backward compatibility
|
||||
pub(crate) use analytics::stats;
|
||||
pub(crate) use auth::{tokens, webauthn};
|
||||
pub(crate) use coffee::{bags, brews, cafes, checkin, cups, gear, roasters, roasts, scan};
|
||||
pub(crate) use system::{admin, backup};
|
||||
|
||||
use axum::extract::DefaultBodyLimit;
|
||||
use axum::routing::{get, post};
|
||||
|
|
|
|||
2
src/application/routes/api/system/mod.rs
Normal file
2
src/application/routes/api/system/mod.rs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
pub(crate) mod admin;
|
||||
pub(crate) mod backup;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::countries::{country_to_iso, iso_to_flag_emoji};
|
||||
use crate::domain::countries::{country_to_iso, iso_to_flag_emoji};
|
||||
|
||||
/// A single country's count for geographic statistics.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
4
src/domain/analytics/mod.rs
Normal file
4
src/domain/analytics/mod.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
pub mod ai_usage;
|
||||
pub mod country_stats;
|
||||
pub mod stats;
|
||||
pub mod timeline;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::country_stats::GeoStats;
|
||||
use crate::domain::country_stats::GeoStats;
|
||||
|
||||
/// Summary statistics for roasts: origins, flavours, and roasters.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
5
src/domain/auth/mod.rs
Normal file
5
src/domain/auth/mod.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
pub mod passkey_credentials;
|
||||
pub mod registration_tokens;
|
||||
pub mod sessions;
|
||||
pub mod tokens;
|
||||
pub mod users;
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
use chrono::{DateTime, NaiveDate, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::ids::{BagId, RoastId};
|
||||
use super::listing::{SortDirection, SortKey};
|
||||
use crate::domain::ids::{BagId, RoastId};
|
||||
use crate::domain::listing::{SortDirection, SortKey};
|
||||
use crate::domain::roasters::Roaster;
|
||||
use crate::domain::roasts::Roast;
|
||||
use crate::domain::timeline::{NewTimelineEvent, TimelineEventDetail};
|
||||
|
|
@ -154,7 +154,7 @@ pub fn bag_timeline_event(
|
|||
},
|
||||
TimelineEventDetail {
|
||||
label: "Amount".to_string(),
|
||||
value: super::formatting::format_weight(bag.amount),
|
||||
value: crate::domain::formatting::format_weight(bag.amount),
|
||||
},
|
||||
],
|
||||
tasting_notes: vec![],
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::ids::{BagId, BrewId, GearId};
|
||||
use super::listing::{SortDirection, SortKey};
|
||||
use crate::domain::ids::{BagId, BrewId, GearId};
|
||||
use crate::domain::listing::{SortDirection, SortKey};
|
||||
use crate::domain::timeline::{NewTimelineEvent, TimelineBrewData, TimelineEventDetail};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
|
|
@ -119,7 +119,7 @@ impl BrewWithDetails {
|
|||
},
|
||||
TimelineEventDetail {
|
||||
label: "Coffee".to_string(),
|
||||
value: super::formatting::format_weight(self.brew.coffee_weight),
|
||||
value: crate::domain::formatting::format_weight(self.brew.coffee_weight),
|
||||
},
|
||||
TimelineEventDetail {
|
||||
label: "Water".to_string(),
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::ids::{CafeId, CupId, RoastId};
|
||||
use super::listing::{SortDirection, SortKey};
|
||||
use crate::domain::ids::{CafeId, CupId, RoastId};
|
||||
use crate::domain::listing::{SortDirection, SortKey};
|
||||
use crate::domain::timeline::{NewTimelineEvent, TimelineEventDetail};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
|
@ -3,8 +3,8 @@ use std::str::FromStr;
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::ids::GearId;
|
||||
use super::listing::{SortDirection, SortKey};
|
||||
use crate::domain::ids::GearId;
|
||||
use crate::domain::listing::{SortDirection, SortKey};
|
||||
use crate::domain::timeline::{NewTimelineEvent, TimelineEventDetail};
|
||||
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Serialize, Deserialize)]
|
||||
7
src/domain/coffee/mod.rs
Normal file
7
src/domain/coffee/mod.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
pub mod bags;
|
||||
pub mod brews;
|
||||
pub mod cafes;
|
||||
pub mod cups;
|
||||
pub mod gear;
|
||||
pub mod roasters;
|
||||
pub mod roasts;
|
||||
|
|
@ -1,24 +1,15 @@
|
|||
pub mod ai_usage;
|
||||
pub mod bags;
|
||||
pub mod brews;
|
||||
pub mod cafes;
|
||||
pub mod analytics;
|
||||
pub mod auth;
|
||||
pub mod coffee;
|
||||
pub mod countries;
|
||||
pub mod country_stats;
|
||||
pub mod cups;
|
||||
pub mod errors;
|
||||
pub mod formatting;
|
||||
pub mod gear;
|
||||
pub mod ids;
|
||||
pub mod listing;
|
||||
pub mod passkey_credentials;
|
||||
pub mod registration_tokens;
|
||||
pub mod repositories;
|
||||
pub mod roasters;
|
||||
pub mod roasts;
|
||||
pub mod sessions;
|
||||
pub mod stats;
|
||||
pub mod timeline;
|
||||
pub mod tokens;
|
||||
pub mod users;
|
||||
|
||||
// Re-exports for backward compatibility
|
||||
pub use analytics::{ai_usage, country_stats, stats, timeline};
|
||||
pub use auth::{passkey_credentials, registration_tokens, sessions, tokens, users};
|
||||
pub use coffee::{bags, brews, cafes, cups, gear, roasters, roasts};
|
||||
pub use errors::RepositoryError;
|
||||
|
|
|
|||
3
src/infrastructure/repositories/analytics/mod.rs
Normal file
3
src/infrastructure/repositories/analytics/mod.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
pub mod ai_usage;
|
||||
pub mod stats;
|
||||
pub mod timeline_events;
|
||||
5
src/infrastructure/repositories/auth/mod.rs
Normal file
5
src/infrastructure/repositories/auth/mod.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
pub mod passkey_credentials;
|
||||
pub mod registration_tokens;
|
||||
pub mod sessions;
|
||||
pub mod tokens;
|
||||
pub mod users;
|
||||
|
|
@ -2,13 +2,13 @@ use async_trait::async_trait;
|
|||
use chrono::{DateTime, NaiveDate, Utc};
|
||||
use sqlx::{QueryBuilder, query_as};
|
||||
|
||||
use super::macros::push_update_field;
|
||||
use crate::domain::RepositoryError;
|
||||
use crate::domain::bags::{Bag, BagFilter, BagSortKey, BagWithRoast, NewBag, UpdateBag};
|
||||
use crate::domain::ids::{BagId, RoastId};
|
||||
use crate::domain::listing::{ListRequest, Page, SortDirection};
|
||||
use crate::domain::repositories::BagRepository;
|
||||
use crate::infrastructure::database::DatabasePool;
|
||||
use crate::infrastructure::repositories::macros::push_update_field;
|
||||
|
||||
const BASE_SELECT: &str = r"
|
||||
SELECT
|
||||
|
|
@ -2,13 +2,13 @@ use async_trait::async_trait;
|
|||
use chrono::{DateTime, Utc};
|
||||
use sqlx::{QueryBuilder, query, query_as};
|
||||
|
||||
use super::macros::push_update_field;
|
||||
use crate::domain::RepositoryError;
|
||||
use crate::domain::cafes::{Cafe, CafeSortKey, NewCafe, UpdateCafe};
|
||||
use crate::domain::ids::CafeId;
|
||||
use crate::domain::listing::{ListRequest, Page, SortDirection};
|
||||
use crate::domain::repositories::CafeRepository;
|
||||
use crate::infrastructure::database::DatabasePool;
|
||||
use crate::infrastructure::repositories::macros::push_update_field;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SqlCafeRepository {
|
||||
|
|
@ -4,13 +4,13 @@ use async_trait::async_trait;
|
|||
use chrono::{DateTime, Utc};
|
||||
use sqlx::{QueryBuilder, query_as};
|
||||
|
||||
use super::macros::push_update_field;
|
||||
use crate::domain::RepositoryError;
|
||||
use crate::domain::gear::{Gear, GearCategory, GearFilter, GearSortKey, NewGear, UpdateGear};
|
||||
use crate::domain::ids::GearId;
|
||||
use crate::domain::listing::{ListRequest, Page, SortDirection};
|
||||
use crate::domain::repositories::GearRepository;
|
||||
use crate::infrastructure::database::DatabasePool;
|
||||
use crate::infrastructure::repositories::macros::push_update_field;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SqlGearRepository {
|
||||
7
src/infrastructure/repositories/coffee/mod.rs
Normal file
7
src/infrastructure/repositories/coffee/mod.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
pub mod bags;
|
||||
pub mod brews;
|
||||
pub mod cafes;
|
||||
pub mod cups;
|
||||
pub mod gear;
|
||||
pub mod roasters;
|
||||
pub mod roasts;
|
||||
|
|
@ -2,13 +2,13 @@ use async_trait::async_trait;
|
|||
use chrono::{DateTime, Utc};
|
||||
use sqlx::{QueryBuilder, query, query_as};
|
||||
|
||||
use super::macros::push_update_field;
|
||||
use crate::domain::RepositoryError;
|
||||
use crate::domain::ids::RoasterId;
|
||||
use crate::domain::listing::{ListRequest, Page, SortDirection};
|
||||
use crate::domain::repositories::RoasterRepository;
|
||||
use crate::domain::roasters::{NewRoaster, Roaster, RoasterSortKey, UpdateRoaster};
|
||||
use crate::infrastructure::database::DatabasePool;
|
||||
use crate::infrastructure::repositories::macros::push_update_field;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SqlRoasterRepository {
|
||||
|
|
@ -3,13 +3,13 @@ use chrono::{DateTime, Utc};
|
|||
use serde_json::{from_str, to_string};
|
||||
use sqlx::{Error as SqlxError, QueryBuilder, query, query_as};
|
||||
|
||||
use super::macros::push_update_field;
|
||||
use crate::domain::RepositoryError;
|
||||
use crate::domain::ids::{RoastId, RoasterId};
|
||||
use crate::domain::listing::{ListRequest, Page, SortDirection};
|
||||
use crate::domain::repositories::RoastRepository;
|
||||
use crate::domain::roasts::{NewRoast, Roast, RoastSortKey, RoastWithRoaster, UpdateRoast};
|
||||
use crate::infrastructure::database::DatabasePool;
|
||||
use crate::infrastructure::repositories::macros::push_update_field;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SqlRoastRepository {
|
||||
|
|
@ -23,4 +23,4 @@ macro_rules! push_update_field {
|
|||
};
|
||||
}
|
||||
|
||||
pub(super) use push_update_field;
|
||||
pub(crate) use push_update_field;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,10 @@
|
|||
pub mod ai_usage;
|
||||
pub mod bags;
|
||||
pub mod brews;
|
||||
pub mod cafes;
|
||||
pub mod cups;
|
||||
pub mod gear;
|
||||
mod macros;
|
||||
pub mod analytics;
|
||||
pub mod auth;
|
||||
pub mod coffee;
|
||||
pub(crate) mod macros;
|
||||
pub mod pagination;
|
||||
pub mod passkey_credentials;
|
||||
pub mod registration_tokens;
|
||||
pub mod roasters;
|
||||
pub mod roasts;
|
||||
pub mod sessions;
|
||||
pub mod stats;
|
||||
pub mod timeline_events;
|
||||
pub mod tokens;
|
||||
pub mod users;
|
||||
|
||||
// Re-exports for backward compatibility
|
||||
pub use analytics::{ai_usage, stats, timeline_events};
|
||||
pub use auth::{passkey_credentials, registration_tokens, sessions, tokens, users};
|
||||
pub use coffee::{bags, brews, cafes, cups, gear, roasters, roasts};
|
||||
|
|
|
|||
Loading…
Reference in a new issue