AxumKit serves as a comprehensive, production-ready template for Rust web APIs, integrating powerful tools like Axum, PostgreSQL, and Redis. Designed with a layered architecture and built-in features such as session-based authentication and background job processing, it streamlines the development of scalable, efficient web applications.
AxumKit is a production-ready web API template built in Rust, leveraging the power and flexibility of Axum, SeaORM, PostgreSQL, Redis, and OAuth2 technologies.
The architecture of AxumKit is distinctly modular:
Error management is centralized through an Errors enum, providing automatic conversion to the appropriate HTTP response status codes. The error handling mechanism varies between development environments (detailed error information) and production settings (safeguarding internal details).
pub async fn handler() -> Result<Json<Response>, Errors> {
let user = repo::get_by_id(&conn, id)
.await
.map_err(|_| Errors::UserNotFound)?;
Ok(Json(response))
}
Customizable through environment variables defined in the .env file, AxumKit allows easy configuration for server settings, authentication, database connections, caching, storage, search options, and more. A sample configuration is provided in the .env.example file.
| Category | Variables |
|---|---|
| Server | HOST, PORT, ENVIRONMENT |
| Auth | TOTP_SECRET, AUTH_SESSION_*, OAUTH_PENDING_SIGNUP_TTL_MINUTES |
| Database | POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_HOST, POSTGRES_PORT, POSTGRES_NAME |
| Redis | REDIS_SESSION_HOST, REDIS_SESSION_PORT, REDIS_CACHE_HOST, REDIS_CACHE_PORT |
| OAuth | GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET |
| Storage | R2_*, SEAWEEDFS_ENDPOINT |
| Search | MEILISEARCH_HOST, MEILISEARCH_API_KEY |
| Queue | NATS_URL |
| CORS | CORS_ALLOWED_ORIGINS, CORS_ALLOWED_HEADERS, CORS_MAX_AGE |
AxumKit is designed for developers looking to streamline the creation of secure and performant web APIs in Rust.
No comments yet.
Sign in to be the first to comment.