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.
make test
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.