4f870ec4c9be4b746c3b161e32cc7fc34c7d5f7c
Axum SurrealDB Boilerplate
Features
- Authentication Ready: Preconfigured authentication and middleware for secure API access.
- Database Integration: SurrealDB seamlessly integrated as an Axum Extension.
- CORS Handling: Fine-tuned CORS management with Tower HTTP
CorsLayer. - API Documentation: Fully documented with OpenAPI and Swagger UI.
- Optimized for Performance: Asynchronous, lightweight, and scalable architecture.
Prerequisites
- Rust: Install Rust from rust-lang.org.
- Database: Set up a SurrealDB instance and configure connection details.
- Docker: Required for containerized deployment, install from docker.com.
- Nix (Optional): For reproducible builds, install from nixos.org.
Getting Started
-
Clone the Repository:
git clone https://github.com/maulanasdqn/axum-surrealdb-boilerplate
-
Set Up Environment Variables:
-
Copy
.env.exampleand rename it to.env -
Windows: Run the script:
./apply-env.ps1 -
Unix-based systems (Linux, macOS, BSD): Run the script:
./apply-env.sh
-
-
Install Dependencies:
cargo install .
-
Setup Database:
- Install the surrealDB
- Windows:
iwr https://windows.surrealdb.com -useb | iex - Unix-based systems (Linux, macOS, BSD):
curl -sSf https://install.surrealdb.com | sh - Start the database
surreal start --user root --pass root
-
Start the Server:
- Install Cargo Watch
cargo install cargo-watch - Run it with cargo watch
cargo watch -x run
The API will be available at
http://localhost:3000/docs. - Install Cargo Watch
Docker
-
Build the Docker Image:
-
Run the Docker Container:
The API will be accessible at
http://localhost:3000/docs.
Using Nix as Builder (Optional)
-
Install Nix:
-
Enter Nix Shell or Use Nix Flakes:
-
Build the Project:
-
Run the Server:
Contributing
Contributions are welcome! Fork the repository and create a pull request with your improvements.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgements
Languages
Rust
97%
Nix
2%
PowerShell
0.4%
Shell
0.4%
Dockerfile
0.2%