clean(presentation): strip comments, kill dead code, extract constants
- remove all doc/inline comments - delete unused ApiError variants (AuthRequired, NotImplemented) and helpers (internal, not_implemented) - prefix lifetime-only AppState fields with _ to suppress dead_code warning - extract magic numbers: TICK_INTERVAL_SECS, EXPIRY_THRESHOLD_HOURS, POLL_INTERVAL_SECS, EVENT_BUS_CAPACITY, DEFAULT_ACTIVITY_LIMIT, DEFAULT_SEARCH_LIMIT, etc - replace inline serde_json::json! in sync_status with typed SyncStatusEntry - fix mid-file import in schedule handler - fix extractors: strip_prefix instead of magic offset 6 - fix unreachable pattern in wire_repositories with cfg guard - use eq_ignore_ascii_case for content-type header check
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
//! k-tv server entry point.
|
||||
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use tower_http::cors::{Any, CorsLayer};
|
||||
@@ -17,10 +15,8 @@ mod state;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
// Load .env file if present
|
||||
let _ = dotenvy::dotenv();
|
||||
|
||||
// Initialize tracing
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
tracing_subscriber::EnvFilter::try_from_default_env()
|
||||
@@ -28,7 +24,6 @@ async fn main() -> anyhow::Result<()> {
|
||||
)
|
||||
.init();
|
||||
|
||||
// Load config
|
||||
let config = infra_wiring::Config::from_env()
|
||||
.map_err(|e| anyhow::anyhow!("Config error: {}", e))?;
|
||||
|
||||
@@ -38,10 +33,8 @@ async fn main() -> anyhow::Result<()> {
|
||||
|
||||
info!("Starting k-tv server on {}:{}", host, port);
|
||||
|
||||
// Build the application state (connects DB, creates adapters, spawns background tasks)
|
||||
let app_state = factory::build_app_state(config).await?;
|
||||
|
||||
// Build CORS layer
|
||||
let cors = if cors_origins.iter().any(|o| o == "*") {
|
||||
CorsLayer::new()
|
||||
.allow_origin(Any)
|
||||
@@ -58,14 +51,12 @@ async fn main() -> anyhow::Result<()> {
|
||||
.allow_headers(Any)
|
||||
};
|
||||
|
||||
// Build the router
|
||||
let app = axum::Router::new()
|
||||
.nest("/api/v1", routes::api_v1_router())
|
||||
.layer(cors)
|
||||
.layer(TraceLayer::new_for_http())
|
||||
.with_state(app_state);
|
||||
|
||||
// Start serving
|
||||
let addr: SocketAddr = format!("{}:{}", host, port).parse()?;
|
||||
let listener = tokio::net::TcpListener::bind(addr).await?;
|
||||
info!("Listening on {}", addr);
|
||||
|
||||
Reference in New Issue
Block a user