feat(server): started friend & reworked deps

This commit is contained in:
Maieul BOYER 2026-02-08 19:35:09 +01:00
parent bd8135e2ad
commit 83433186f3
Signed by: maix
SSH key fingerprint: SHA256:iqCzqFFF5KjRixmDExqbAltCIj9ndlBWIGJf3t9Ln9g
7 changed files with 328 additions and 7 deletions

View file

@ -1,4 +1,79 @@
/*
{ f_front.py
[ SEND FROM STATIC DIRECTORY
/static/<path>
/favicon.ico
/manifest.json
/service_worker.json
/apple-touch-icon.png
]
/
/settings
/profile/{login}
/search/<keyword>/<int:friends_only>
/friends
}
{ f_friends.py
/friends/add/<add>
/friends/remove/<remove>
/friends/set_relation/<who>/<int:relation>
}
{ f_issues.py
/addissue/<pc>/<int:issue_type>
}
{ f_locations.py
/goto/<pos>
}
{ f_users.py
/getuser/<login>
/settings/profile [POST]
}
*/
use std::sync::Arc;
use axum::Router;
use log::info;
use tower_http::trace::TraceLayer;
use tracing_subscriber::EnvFilter;
mod friends;
#[derive(Clone, Debug)]
struct GlobalState {
templates: Arc<minijinja::Environment<'static>>,
}
#[tokio::main]
async fn main() {
println!("Hello, world!");
tracing_subscriber::fmt()
// This allows you to use, e.g., `RUST_LOG=info` or `RUST_LOG=debug`
// when running the app to set log levels.
.with_env_filter(
EnvFilter::try_from_default_env()
.or_else(|_| EnvFilter::try_new("froxy_server=error,tower_http=warn"))
.unwrap(),
)
.init();
let mut env = minijinja::Environment::new();
froxy_templates::friends::add_to_context(&mut env);
let global_state = GlobalState {
templates: Arc::new(env),
};
let app = Router::new()
.merge(friends::router())
.with_state(global_state)
.layer(TraceLayer::new_for_http());
let (ip, port) = ("0.0.0.0", 3000);
info!("Starting server on {ip}:{port}");
// run our app with hyper, listening globally on port 3000
let listener = tokio::net::TcpListener::bind((ip,port)).await.unwrap();
axum::serve(listener, app).await.unwrap();
}