Hi! rubete is short for "Rust backend template". It is a boilerplate backend API built with Rust and the Ntex web framework. It provides a solid foundation for building RESTful APIs.
- User authentication and management.
- Connection to MySQL database. Using SeaORM as the ORM layer.
- Easy to understand and extend, as long as you follow the existing structure and understand Rust and Ntex basics. Everything starts from
main.rs. Thesrcdirectory contains the core application logic, organized into subdirectories for different modules and functionalities. - Environment configuration using
.envfile.
- Provide a robust and scalable backend for any web application.
- Ensure security and efficiency in handling user data and requests.
- Facilitate easy integration with frontend applications and other services.
- Maintain clean and maintainable codebase for future development.
- Follow best practices in Rust programming and web development.
- Support OpenAPI/Swagger documentation for easy API exploration and testing.
- Implement comprehensive error handling and logging.
- Use middleware for tasks like logging, CORS, and authentication.
- Enable hot reloading during development for faster iteration.
- Support deployment in various environments, including local, staging, and production.
- Unit and integration testing to ensure code quality and reliability.
To get started with the rubete API, follow these steps:
-
Clone the repository:
git clone https://github.com/sonyarianto/rubete.git
-
Navigate to the project directory:
cd rubete -
Install the required dependencies:
cargo build
-
Set up your environment variables: Copy the
.env.examplefile to.envand fill in the required values. -
Run the application:
cargo run
6. The API will be available at `http://localhost:9000` (or the port you specified in the `.env` file).
## Hot reload during development
For development, you can use `cargo-watch` for hot reloading. Install it using:
```bash
cargo install cargo-watch
Then run:
cargo watch -x runTo generate SeaORM entities from your existing database schema, you can use the sea-orm-cli tool. Install it using:
cargo install sea-orm-cliThen run the following command to generate entities:
sea-orm-cli generate entity -u mysql://username:password@localhost/database_name -o src/entityThis project using lefthook for Git hooks. Follow the instructions at lefthook installation guide.
Run the following command to install the Git hooks defined in this project:
lefthook installThis will set up the pre-commit hook to run commands before each commit. See on lefthook.yml for more details.
- Add unit and integration tests.
- Implement more advanced features like role-based access control.
- Audit logging and monitoring.
- Better documentation and examples.
- Docker support for easier deployment.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
- Sony AK - [email protected]