From 3ad00bdcba094cb116485404f5d0491405abe319 Mon Sep 17 00:00:00 2001 From: Ryan Walters Date: Thu, 18 Sep 2025 13:18:53 -0500 Subject: [PATCH] chore: setup lib for testing, image handling notes in README --- Cargo.lock | 5 +++++ pacman-server/Cargo.toml | 12 ++++++++++++ pacman-server/README.md | 16 ++++++++++++++++ pacman-server/src/lib.rs | 11 ++++++++++- 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index b1181d2..2f16bcc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2677,14 +2677,19 @@ version = "0.1.1" name = "pacman-server" version = "0.4.0" dependencies = [ + "anyhow", "async-trait", "axum", "axum-cookie", + "bytes 1.10.1", "chrono", "dashmap", "dotenvy", "fast_image_resize", "figment", + "http", + "hyper", + "hyper-util", "image", "jsonwebtoken", "oauth2", diff --git a/pacman-server/Cargo.toml b/pacman-server/Cargo.toml index 58057eb..463f647 100644 --- a/pacman-server/Cargo.toml +++ b/pacman-server/Cargo.toml @@ -14,6 +14,10 @@ categories.workspace = true publish.workspace = true default-run = "pacman-server" +[lib] +name = "pacman_server" +path = "src/lib.rs" + [dependencies] axum = { version = "0.8", features = ["macros"] } tokio = { version = "1", features = ["full"] } @@ -44,3 +48,11 @@ fast_image_resize = { version = "5.3", features = ["image"] } image = { version = "0.25", features = ["png", "jpeg"] } sha2 = "0.10" # validator = { version = "0.16", features = ["derive"] } + +[dev-dependencies] +tokio = { version = "1", features = ["full"] } +http = "1" +hyper = { version = "1", features = ["server", "http1"] } +hyper-util = { version = "0.1", features = ["server", "tokio", "http1"] } +bytes = "1" +anyhow = "1" diff --git a/pacman-server/README.md b/pacman-server/README.md index 96420e0..d3a484d 100644 --- a/pacman-server/README.md +++ b/pacman-server/README.md @@ -45,3 +45,19 @@ This crate is a webserver that hosts an OAuth login and leaderboard API for the 13. API Rate Limiting (inbound requests, by IP, by User) 14. Provider Circuit Breaker 15. Merge migration files + +## Notes + +### Image Handling + +Avatar images are stored in S3 as follows: + +- `avatars/{user_public_id}/{avatar_hash}.original.png` +- `avatars/{user_public_id}/{avatar_hash}.mini.png` + +- The original image is converted to PNG and resized to a maximum of 512x512 pixels. + - Ideally, non-square images are fitted to a square. +- The mini image is converted to PNG and resized to a maximum of 16x16, 24x24, or 32x32 pixels. TBD. +- All images receive a Content-Type header of `image/png`. + +Image processing is handled immediately asynchronously, allowing a valid presigned URL to be generated immediately. diff --git a/pacman-server/src/lib.rs b/pacman-server/src/lib.rs index 8b13789..0487ee0 100644 --- a/pacman-server/src/lib.rs +++ b/pacman-server/src/lib.rs @@ -1 +1,10 @@ - +pub mod app; +pub mod auth; +pub mod config; +pub mod data; +pub mod errors; +pub mod formatter; +pub mod image; +pub mod logging; +pub mod routes; +pub mod session;