Skip to content
/ rsapi Public template

A high-performance API template built with Axum, designed for rapid development of secure and maintainable web services.

License

Notifications You must be signed in to change notification settings

atopx/rsapi

Repository files navigation

RSAPI - Rust API Framework

A high-performance API template built with Axum, designed for rapid development of secure and maintainable web services.

Rust GitHub release GitHub stars GitHub forks GitHub 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

    cp .env.sample .env
    # Update variables in .env file
  2. Database Setup

Ensure PostgreSQL is running with credentials matching your .env configuration.

Initialize the database and table: sys_tables

  1. 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

About

A high-performance API template built with Axum, designed for rapid development of secure and maintainable web services.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published