rustapi
RESTful API template built with Rust lang. It uses MongoDB database and Axum HTTP framework.
Requirements
How to use this template
To use this template as your project starting point, click "Use this template" at the top of this page, or click here.
Feature highlights
- Authentication. Based on jsonwebtoken
- Layered configuration. Based on config-rs
- Logs. Based on tracing
- Error handling
- Pagination
- E2E Tests
- OpenAPI Specification
- CI based on Github actions
- Dependabot configuration
Project structure
βββ Cargo.lock
βββ Cargo.toml
βββ README.md
βββ config
β βββ default.json # Default configuration
β βββ production.json # Production configuration (Overwrites the default)
β βββ test.json # Test configuration (Overwrites the default)
βββ rustfmt.toml
βββ src
β βββ database.rs
β βββ errors.rs
β βββ lib # Helpers not related to the business model
β β βββ authenticate_request.rs
β β βββ date.rs
β β βββ mod.rs
β β βββ models.rs # Base Database Model trait
β β βββ to_object_id.rs
β β βββ token.rs
β βββ logger.rs
β βββ main.rs
β βββ models
β β βββ cat.rs
β β βββ mod.rs
β β βββ user.rs
β βββ routes
β β βββ cat.rs
β β βββ mod.rs
β β βββ status.rs
β β βββ user.rs
β βββ settings.rs
β βββ tests # E2E Tests
βββ test.sh
Test
To run tests make sure MongoDB is up and running.
./test.sh
Contributing
Contributors are welcome, please fork and send pull requests! If you find a bug or have any ideas on how to improve this project please submit an issue.