RSAPI - Rust API Framework
May 9, 2025 ยท View on GitHub
A high-performance API template built with Axum, designed for rapid development of secure and maintainable web services.
Features
- ๐ Production-Ready Fast and minimalistic web framework
- ๐ JWT Authentication Secure token-based authentication system
- โฐ Cron Scheduler
Built-in task scheduling with
tokio-cron-scheduler - ๐ฆ ORM Integration Database operations via SeaORM with PostgreSQL
- ๐ก Observability Integrated tracing and structured logging
- ๐ก๏ธ Security CORS middleware and secure headers
- ๐ณ Minimal docker image 12.9MB Docker image with Alpine base
Tech Stack
Core Components:
- Axum 0.8 (Web Framework)
- SeaORM 1.x (PostgreSQL ORM)
- JSON Web Tokens (JWT)
- Tokio 1.x (Async Runtime)
Infrastructure:
- Dockerized deployment
- Multi-stage build optimization
- Alpine Linux base image
Quick Start
-
Environment Setup
cp .env.sample .env # Update variables in .env file -
Database Setup
Ensure PostgreSQL is running with credentials matching your .env configuration.
Initialize the database and table: sys_tables
-
Run with Docker
docker-compose up --build -d
API Examples
User Login :
curl -X POST http://localhost:6000/api/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"your_password"}'
Get User Claims :
curl -X GET http://localhost:6000/api/claims \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Scheduled Tasks
CRONTAB_EXAMPLE="*/5 * * * * *" # Every 5 seconds
Task implementations are in [schedule::example](./src/schedule/mod.rs) .
Development
Build optimized binary:
cargo build --release
Run tests (ensure test database is configured):
cargo test -- --test-threads=1
License: MIT