diff options
author | rtkay123 <dev@kanjala.com> | 2025-07-17 14:00:40 +0200 |
---|---|---|
committer | rtkay123 <dev@kanjala.com> | 2025-07-17 14:00:40 +0200 |
commit | 69fe55ad54468948c13af520a498ed4aeac194ed (patch) | |
tree | c7db25aa7cf615480e9b386064f232d2bec6ccc3 /src/server.rs | |
parent | 5fdb24b6a2cef7964a049e789ed90f883221d657 (diff) | |
download | sellershut-69fe55ad54468948c13af520a498ed4aeac194ed.tar.bz2 sellershut-69fe55ad54468948c13af520a498ed4aeac194ed.zip |
chore: convert to workspace
Diffstat (limited to 'src/server.rs')
-rw-r--r-- | src/server.rs | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/server.rs b/src/server.rs deleted file mode 100644 index dd49a54..0000000 --- a/src/server.rs +++ /dev/null @@ -1,49 +0,0 @@ -use activitypub_federation::config::{FederationConfig, FederationMiddleware}; -use axum::{Router, routing::get}; -use nanoid::nanoid; -use stack_up::Environment; -use tower_http::trace::TraceLayer; -use url::Url; - -use crate::{error::AppError, server::routes::health_check, state::AppHandle}; - -pub mod activities; -pub mod routes; - -const ALPHABET: [char; 36] = [ - '2', '3', '4', '5', '6', '7', '8', '9', '_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', - 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '-', -]; - -pub fn generate_object_id(domain: &str, env: Environment) -> Result<Url, AppError> { - let id = nanoid!(21, &ALPHABET); - Ok(Url::parse(&format!( - "{}://{domain}/objects/{id}", - match env { - Environment::Development => "http", - Environment::Production => "https", - }, - ))?) -} - -pub fn router(state: FederationConfig<AppHandle>) -> Router { - Router::new() - .merge(routes::users::users_router()) - .route("/", get(health_check)) - .layer(TraceLayer::new_for_http()) - .layer(FederationMiddleware::new(state)) -} - -#[cfg(test)] -pub(crate) fn test_config() -> stack_up::Configuration { - use stack_up::Configuration; - - let config_path = "sellershut.toml"; - - let config = config::Config::builder() - .add_source(config::File::new(config_path, config::FileFormat::Toml)) - .build() - .unwrap(); - - config.try_deserialize::<Configuration>().unwrap() -} |