use std::path::PathBuf;
use axum::Router;
use axum::extract::DefaultBodyLimit;
use tower_http::services::ServeDir;
pub const PROTECTED_API_BODY_LIMIT_BYTES: usize = 220 * 1024 * 1024;
pub fn layer_protected_body_limit<S>(router: Router<S>) -> Router<S>
where
S: Clone + Send + Sync + 'static,
{
router.layer(DefaultBodyLimit::max(PROTECTED_API_BODY_LIMIT_BYTES))
}
pub fn mount_uploads_and_spa<S>(mut app: Router<S>, static_dir: Option<PathBuf>) -> Router<S>
where
S: Clone + Send + Sync + 'static,
{
if let Some(dir) = static_dir {
app = app.fallback_service(ServeDir::new(dir));
}
app
}