# laxum-web **Repository Path**: lauset/laxum-web ## Basic Information - **Project Name**: laxum-web - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-21 - **Last Updated**: 2025-12-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # laxum web `laxum-web` is a web application framework based on axum encapsulation. ## Tell you something - The web service is based on [`axum`]. - The database uses [`sqlx`]. - The NoSQL database uses [`bb8-redis`]. - The task scheduling framework uses [`tokio-cron-scheduler`]. - The API authentication uses [`jsonwebtoken`]. ## Usage example ```rust mod api; mod entity; mod task; use laxum_web::app; use laxum_web::config; use laxum_web::task::TaskRegistry; #[tokio::main] async fn main() -> anyhow::Result<()> { // config file config::init_config(env!("CARGO_MANIFEST_DIR")).expect("Failed to initialize config"); // init task let mut registry = TaskRegistry::new(); task::init_tasks(&mut registry); // run server app::run(api::create_router(), registry).await } ``` ## Config File application.yaml ```yaml server: port: 3001 jwt: secret: 123456 expiration: 7200 database: host: 127.0.0.1 port: 3307 user: root password: 123456 database: db_name schema: redis: host: 127.0.0.1 port: 6379 db: 0 ``` ## authentication Add `route_layer(auth_layer())` ```rust use laxum_web::app::auth::auth_layer; pub fn create_router() -> Router { Router::new() .nest( "/api", Router::new() .nest("/user-info", user_info::create_router()) // need verify token .route_layer(auth_layer()) .nest("/login", login::create_router()) ) } ``` Generate jwt token ```rust use laxum_web::app::jwt::{Principal, get_jwt}; fn test() { let principal = Principal { id: "1001".to_string(), name: "admin".to_string() }; let access_token = get_jwt().encode(principal)?; tracing::info!("JWT Token: {access_token}"); } ``` ## Safety 100% safe Rust. ## Minimum supported Rust version Consistent with axum. 1.78.x ## Examples The [examples] folder contains various examples of how to use `laxum-web`. ## License This project is licensed under the `MIT license` [examples]: examples [`axum`]: https://github.com/tokio-rs/axum [`sqlx`]: https://github.com/launchbadge/sqlx [`bb8-redis`]: https://github.com/djc/bb8 [`tokio-cron-scheduler`]: https://github.com/mvniekerk/tokio-cron-scheduler [`jsonwebtoken`]: https://github.com/Keats/jsonwebtoken