- Changed root div ID from 'root' to 'app' in index.html. - Updated package.json to include new dependencies for routing and state management. - Removed App component and replaced it with a router setup in main.tsx. - Added route definitions for login, about, and index pages. - Implemented authentication logic using Zustand for state management. - Created API client with Axios for handling requests and token management. - Added CORS support in the backend API. - Updated schema for login requests to use camelCase.
50 lines
1.3 KiB
Rust
50 lines
1.3 KiB
Rust
use std::net::SocketAddr;
|
|
|
|
use tower_http::cors::CorsLayer;
|
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
|
|
|
pub mod config;
|
|
pub mod error;
|
|
pub mod extractors;
|
|
pub mod factory;
|
|
pub mod handlers;
|
|
pub mod middleware;
|
|
pub mod routes;
|
|
pub mod schema;
|
|
pub mod security;
|
|
pub mod services;
|
|
pub mod state;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> anyhow::Result<()> {
|
|
let config = config::load_config()?;
|
|
|
|
tracing_subscriber::registry()
|
|
.with(
|
|
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
|
|
format!("{}=debug,tower_http=debug", env!("CARGO_CRATE_NAME")).into()
|
|
}),
|
|
)
|
|
.with(tracing_subscriber::fmt::layer())
|
|
.init();
|
|
|
|
let addr: SocketAddr = config.server_address.parse()?;
|
|
|
|
let app_state = factory::build_app_state(config).await?;
|
|
let max_upload_size =
|
|
(app_state.config.max_upload_size_mb.unwrap_or(100) * 1024 * 1024) as usize;
|
|
|
|
let cors = CorsLayer::permissive();
|
|
let app = routes::api_routes(max_upload_size)
|
|
.layer(cors)
|
|
.with_state(app_state);
|
|
|
|
println!("Starting server at http://{}", addr);
|
|
|
|
let listner = tokio::net::TcpListener::bind(addr).await?;
|
|
|
|
axum::serve(listner, app.into_make_service()).await?;
|
|
|
|
Ok(())
|
|
}
|