ndelvalle / rustapi

πŸš€ RESTful Rust API Template / Boilerplate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rustapi

Tests

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.

About

πŸš€ RESTful Rust API Template / Boilerplate


Languages

Language:Rust 99.1%Language:Makefile 0.9%