Phase 2.1: Backend project initialized with Docker configuration
- Created Cargo.toml with all required dependencies - Implemented health/ready endpoints - Added Docker configuration (production + development) - Configured docker-compose with resource limits - Set up MongoDB service with persistence - Verified build (cargo check passed) - Prepared monorepo structure for mobile/web/shared Next: Phase 2.2 (MongoDB connection and models)
This commit is contained in:
parent
4dca44dbbe
commit
1e38fe3ace
11 changed files with 388 additions and 80 deletions
52
backend/src/main.rs
Normal file
52
backend/src/main.rs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
use axum::{
|
||||
routing::get,
|
||||
Router,
|
||||
response::Json,
|
||||
};
|
||||
use serde_json::json;
|
||||
use tower_http::trace::TraceLayer;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tracing_subscriber::registry()
|
||||
.with(
|
||||
tracing_subscriber::EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| "normogen_backend=debug,tower_http=debug,axum=debug".into()),
|
||||
)
|
||||
.with(tracing_subscriber::fmt::layer())
|
||||
.init();
|
||||
|
||||
tracing::info!("Starting Normogen backend server");
|
||||
|
||||
let app = Router::new()
|
||||
.route("/health", get(health_check))
|
||||
.route("/ready", get(readiness_check))
|
||||
.layer(TraceLayer::new_for_http());
|
||||
|
||||
let addr = std::net::SocketAddr::from(([0, 0, 0, 0], 8000));
|
||||
tracing::info!("Listening on {}", addr);
|
||||
|
||||
let listener = tokio::net::TcpListener::bind(addr)
|
||||
.await
|
||||
.expect("Failed to bind address");
|
||||
|
||||
axum::serve(listener, app)
|
||||
.await
|
||||
.expect("Server error");
|
||||
}
|
||||
|
||||
async fn health_check() -> Json<serde_json::Value> {
|
||||
Json(json!({
|
||||
"status": "ok",
|
||||
"timestamp": chrono::Utc::now().to_rfc3339(),
|
||||
}))
|
||||
}
|
||||
|
||||
async fn readiness_check() -> Json<serde_json::Value> {
|
||||
Json(json!({
|
||||
"status": "ready",
|
||||
"database": "not_connected",
|
||||
"timestamp": chrono::Utc::now().to_rfc3339(),
|
||||
}))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue