Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detailed API Examples With Shuttle + ActixWeb + Turso #199

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions actix-web/detailed-api-examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target
.shuttle*
Secrets*.toml
28 changes: 28 additions & 0 deletions actix-web/detailed-api-examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "detailed-api-examples"
version = "0.1.0"
edition = "2021"

[dependencies]
actix-web = "4.1.0"
actix-files = "*"
dotenv = "0.15.0"
env_logger = "0.9.0"
log = "0.4.17"
tera = "1.16.0"
serde = {version = "*", features = ["derive"]}
actix-session = {version="0.6.2", features= ["cookie-session"]}
actix-redis = "0.11.0"
validator = { version = "0.15", features = ["derive"] }
bcrypt = "0.13.0"
actix-cors = "0.7.0"
rand = "0.8.5"
actix-multipart = "0.6.1"
futures-util = "0.3"
sha2 = "0.10.8"
chrono = "0.4.39"
base64 = "0.22.1"
shuttle-actix-web = "0.49.0"
shuttle-runtime = "0.49.0"
tokio = "1.26.0"
libsql = "0.6.0"
97 changes: 97 additions & 0 deletions actix-web/detailed-api-examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
About the Project



This project is an API server developed using the Rust programming language. It leverages the Actix Web framework

for handling HTTP-based requests and integrates with the Turso database for performing various data operations.



Technologies Used

- Actix Web: A fast and powerful web framework.

- Actix Session: Used for session management.

- Turso Database: A fast and remote database solution.

- dotenv: For managing environment variables easily.

- Shuttle Runtime: A cloud solution for quickly deploying and running the project.



API Endpoints

| Method | Endpoint | Description |

|--------|--------------------|----------------------------|

| POST | /api/user/create | Creates a new user. |

| POST | /api/user/login | Handles user login. |

| POST | /api/news/upload | Uploads news. |

| POST | /api/events/upload | Uploads events. |

| GET | /api/get | Fetches data. |

| GET | /api/get/a | Fetches statistics. |

| POST | /api/check/token | Verifies a token. |



Setting Up the Development Environment



1. Clone the Repository:

git clone https://github.com/shuttle-hq/shuttle-examples/detailed-api-examples/

cd shuttle-examples/detailed-api-examples/



2. Install Required Dependencies:

Use Cargo to install the dependencies:

cargo build



3. Configure Environment Variables:

Add the following keys to your Secrets.toml file:

TURSO_DATABASE_URL=<database-url>

TURSO_AUTH_TOKEN=<auth-token>



4. Run the Project:

cargo run



Deploying the Project with Shuttle



1. Install Shuttle CLI:

cargo install cargo-shuttle



2. Deploy the Project:

cargo shuttle deploy

"""
Binary file added actix-web/detailed-api-examples/database.db
Binary file not shown.
Loading