chore(server): scaffold axum com health endpoint e testes

This commit is contained in:
2026-08-05 20:23:09 -03:00
parent bfe12ba7ae
commit bc4de69ab9
11 changed files with 2013 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
use std::env;
#[derive(Clone, Debug)]
pub struct Config {
pub host: String,
pub port: u16,
pub db_path: String,
pub max_body_mb: usize,
pub max_results: i64,
}
impl Default for Config {
fn default() -> Self {
Self {
host: "127.0.0.1".into(),
port: 3000,
db_path: "data/aresnext.db".into(),
max_body_mb: 2,
max_results: 50,
}
}
}
impl Config {
pub fn from_env() -> Self {
let def = Self::default();
Self {
host: env::var("ARS_NEXT_HOST").unwrap_or(def.host),
port: env::var("ARS_NEXT_PORT")
.ok()
.and_then(|s| s.parse().ok())
.unwrap_or(def.port),
db_path: env::var("ARS_NEXT_DB").unwrap_or(def.db_path),
max_body_mb: env::var("ARS_NEXT_MAX_BODY_MB")
.ok()
.and_then(|s| s.parse().ok())
.unwrap_or(def.max_body_mb),
max_results: env::var("ARS_NEXT_MAX_RESULTS")
.ok()
.and_then(|s| s.parse().ok())
.unwrap_or(def.max_results),
}
}
pub fn max_body_bytes(&self) -> usize {
self.max_body_mb * 1024 * 1024
}
}