added the server with a health check

added .env.example, also removed the old empty config file
This commit is contained in:
2026-07-16 11:48:58 -05:00
parent c234d62d53
commit 34a046fb9a
7 changed files with 459 additions and 8 deletions
-1
View File
@@ -14,7 +14,6 @@ diesel = { version = "2.2.0", features = [
] }
clap = { version = "4.6.1", features = ["derive", "cargo"] }
serde = { version = "1.0.228", features = ["derive"] }
tokio = { version = "1.52.3", features = ["full"] }
uuid = { version = "1.23.5", features = ["v4"] }
crypto = { path = "../crypto" }
keyring = "4.1.4"
+8
View File
@@ -0,0 +1,8 @@
[package]
name = "server"
version = "0.1.0"
edition = "2024"
[dependencies]
axum = { version = "0.8.9", features = ["tokio", "ws"] }
tokio = { version = "1.52.3", features = ["full"] }
+28
View File
@@ -0,0 +1,28 @@
use axum::{Router, routing::get};
use tokio::net::TcpListener;
#[tokio::main]
async fn main() {
let app = Router::new().route("/health", get(health_check));
let address = {
let port = std::env::var("PORT")
.unwrap_or_else(|_| "8080".to_string())
.parse::<u16>()
.expect("PORT must be a valid u16");
let host = std::env::var("HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
format!("{}:{}", host, port)
};
let listener = TcpListener::bind(&address)
.await
.expect("Failed to bind to address");
println!("Server running on http://{}", address);
axum::serve(listener, app).await.unwrap();
}
async fn health_check() -> &'static str {
"OK"
}