feat(altyapı): yerel MongoDB, Axum backend ve Vite frontend iskeleti
- docker-compose.dev.yml: MongoDB 7, tek düğümlü replica set (port 27020) - Backend: Axum + tokio, GET /api/health - Frontend: React + TypeScript + Vite, /api proxy, geçici durum ekranı - Kök package.json: npm run dev ile DB + backend + frontend - backend/api.http örnek istekler Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use axum::{Json, Router, routing::get};
|
||||
use serde_json::{Value, json};
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// .env dosyasını yükle (proje kökünde; üst klasörler de aranır). Yoksa sorun değil.
|
||||
dotenvy::dotenv().ok();
|
||||
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("kakeibo=info")),
|
||||
)
|
||||
.init();
|
||||
|
||||
let port: u16 = std::env::var("PORT")
|
||||
.ok()
|
||||
.and_then(|p| p.parse().ok())
|
||||
.unwrap_or(8080);
|
||||
|
||||
let app = Router::new().route("/api/health", get(health));
|
||||
|
||||
let addr = SocketAddr::from(([0, 0, 0, 0], port));
|
||||
let listener = tokio::net::TcpListener::bind(addr)
|
||||
.await
|
||||
.expect("Port dinlenemedi");
|
||||
tracing::info!("Kakeibo API çalışıyor: http://localhost:{port}");
|
||||
axum::serve(listener, app).await.expect("Sunucu hatası");
|
||||
}
|
||||
|
||||
/// Sağlık kontrolü. Faz 1'de veritabanı durumu da eklenecek.
|
||||
async fn health() -> Json<Value> {
|
||||
Json(json!({ "status": "ok", "version": env!("CARGO_PKG_VERSION") }))
|
||||
}
|
||||
Reference in New Issue
Block a user