first commit

This commit is contained in:
2026-05-18 22:32:23 +02:00
commit 2cf50b0168
10 changed files with 2045 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
use axum::Router;
use axum::routing::get;
use crate::env;
pub async fn start_api(config: env::EnvConfig) -> anyhow::Result<()> {
let app = Router::new().route("/", get(root));
let listerner = tokio::net::TcpListener::bind(format!("0.0.0.0:{}", config.http_port)).await?;
axum::serve(listerner, app)
.await
.map_err(|e| anyhow::anyhow!(e))
}
async fn root() -> &'static str {
"Hello, World!"
}
View File
+19
View File
@@ -0,0 +1,19 @@
use dotenvy::dotenv;
pub struct EnvConfig {
pub http_port: u16,
pub bot_name: String,
}
pub fn load_config() -> anyhow::Result<EnvConfig> {
dotenv().ok();
let http_port = std::env::var("HTTP_PORT")?.parse()?;
let bot_name = std::env::var("BOT_NAME")?;
Ok(EnvConfig {
http_port,
bot_name,
})
}
View File
+9
View File
@@ -0,0 +1,9 @@
mod api;
mod env;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = env::load_config()?;
api::start_api(config).await
}