https://github.com/atopx/rsapi
A high-performance API template built with Axum, designed for rapid development of secure and maintainable web services.
https://github.com/atopx/rsapi
axum postgresql rest-api rust sea-orm template
Last synced: 10 months ago
JSON representation
A high-performance API template built with Axum, designed for rapid development of secure and maintainable web services.
- Host: GitHub
- URL: https://github.com/atopx/rsapi
- Owner: atopx
- License: mit
- Created: 2025-04-12T17:56:26.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2025-04-12T18:28:47.000Z (10 months ago)
- Last Synced: 2025-04-12T19:22:33.629Z (10 months ago)
- Topics: axum, postgresql, rest-api, rust, sea-orm, template
- Language: Rust
- Homepage:
- Size: 40 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RSAPI - Rust API Framework
A high-performance API template built with Axum, designed for rapid development of secure and maintainable web services.
[](https://www.rust-lang.org/)
[](https://github.com/atopx/rsapi/releases)
[](https://github.com/atopx/rsapi/stargazers)
[](https://github.com/atopx/rsapi/network)
[](https://github.com/atopx/rsapi/issues)
## 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.6 (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
1. **Environment Setup**
```bash
cp .env.sample .env
# Update variables in .env file
```
2. **Database Setup**
Ensure PostgreSQL is running with credentials matching your [.env](./.env.sample) configuration.
Initialize the database and table: [sys_tables](./docs/sys_table.sql)
1. Run with Docker
```bash
docker-compose up --build -d
```
## API Examples
#### User Login :
```bash
curl -X POST http://localhost:6000/api/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"your_password"}'
```
#### Get User Claims :
```bash
curl -X GET http://localhost:6000/api/claims \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
```
## Scheduled Tasks
```bash
CRONTAB_EXAMPLE="*/5 * * * * *" # Every 5 seconds
```
Task implementations are in `[schedule::example](./src/schedule/mod.rs)` .
## Development
Build optimized binary:
```bash
cargo build --release
```
Run tests (ensure test database is configured):
```bash
cargo test -- --test-threads=1
```
---
License: [MIT](./LICENSE)