mirror of
https://github.com/Xevion/xevion.dev.git
synced 2026-01-31 14:26:37 -06:00
refactor: reorganize Rust codebase into modular handlers and database layers
- Split monolithic src/db.rs (1122 lines) into domain modules: projects, tags, settings - Extract API handlers from main.rs into separate handler modules by domain - Add proxy module for ISR/SSR coordination with Bun process - Introduce AppState for shared application context - Add utility functions for asset serving and request classification - Remove obsolete middleware/auth.rs in favor of session checks in handlers
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{auth::SessionManager, health::HealthChecker, tarpit::TarpitState};
|
||||
|
||||
/// Application state shared across all handlers
|
||||
#[derive(Clone)]
|
||||
pub struct AppState {
|
||||
pub downstream_url: String,
|
||||
pub http_client: reqwest::Client,
|
||||
pub unix_client: Option<reqwest::Client>,
|
||||
pub health_checker: Arc<HealthChecker>,
|
||||
pub tarpit_state: Arc<TarpitState>,
|
||||
pub pool: sqlx::PgPool,
|
||||
pub session_manager: Arc<SessionManager>,
|
||||
}
|
||||
|
||||
/// Errors that can occur during proxying to Bun
|
||||
#[derive(Debug)]
|
||||
pub enum ProxyError {
|
||||
Network(reqwest::Error),
|
||||
Other(String),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ProxyError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
ProxyError::Network(e) => write!(f, "Network error: {e}"),
|
||||
ProxyError::Other(s) => write!(f, "{s}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for ProxyError {}
|
||||
Reference in New Issue
Block a user