| Crates.io | sword-rs |
| lib.rs | sword-rs |
| version | 0.1.0 |
| created_at | 2025-11-28 16:32:45.879399+00 |
| updated_at | 2025-11-28 16:32:45.879399+00 |
| description | A backend framework built on Axum and SeaORM for rapid API development |
| homepage | https://github.com/mateusramos/sword |
| repository | https://github.com/mateusramos/sword |
| max_upload_size | |
| id | 1955617 |
| size | 99,204 |
sword-rs)The core library of the Sword ecosystem.
Part of Sword — an ecosystem of libraries and tools designed to bring both performance and productivity to backend development and distributed systems in Rust.
This library provides batteries-included utilities built on Axum and SeaORM, letting you focus on business logic instead of boilerplate.
tracingAdd to your Cargo.toml:
[dependencies]
sword = { package = "sword-rs", version = "0.1" }
use sword::{server::run_with_migrator, FrameworkContext};
use axum::{Router, routing::get};
// Your migrator (from sea-orm-migration)
struct Migrator;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenvy::dotenv().ok();
sword::tracing::init_tracing();
run_with_migrator::<Migrator, _>(build_router, true).await
}
fn build_router(ctx: &FrameworkContext) -> Router {
Router::new()
.route("/health", get(|| async { "OK" }))
.with_state(ctx.clone())
}
The framework reads configuration from environment variables:
| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Required |
APP_HOST |
Server bind host | 0.0.0.0 |
APP_PORT |
Server bind port | 3000 |
RUST_LOG |
Log level filter | info,sqlx=warn,sea_orm=info |
DB_MAX_CONNECTIONS |
Maximum database connections | 100 |
DB_MIN_CONNECTIONS |
Minimum database connections | 5 |
DB_CONNECT_TIMEOUT |
Connection timeout (seconds) | 8 |
DB_IDLE_TIMEOUT |
Idle connection timeout (seconds) | 600 |
DB_MAX_LIFETIME |
Max connection lifetime (seconds) | 1800 |
config - Application configuration from environment variablesdb - Database connection with SeaORMserver - Axum server setup and executiontracing - Structured logging initializationFor quickly scaffolding new projects, download the Sword CLI from GitHub Releases:
sword new my-api
See the main repository for installation instructions.
MIT