This is a practice project for building a Rust API using Actix web framework, Serde for serialization/deserialization, Diesel for database interaction, and PostgreSQL as the database.
Make sure you have the following installed before running the project:
-
Clone the repository:
git clone https://github.com/NashTech-Labs/rust-api-with-actix-diesel.git
-
Navigate to the project directory:
cd test-api-rust
- Build the project using cargo:
cargo build --release
- Run the database migrations (you will need to install diesel_cli first):
diesel migration run
- Start the server:
cargo run
src/
|-- main.rs # Application entry point
|-- models/ # Database models
|-- routes/ # API routes and handlers
|-- schema.rs # Generated by Diesel, represents the database schema
|-- db.rs # Database initialization and connection
|-- .env.example # Example environment file
|-- diesel.toml # Diesel configuration file
+ `GET /tweets`: Get all tweets.
+ `GET /tweets/{id}`: Get a tweet by ID.
+ `POST /tweets`: Create a new tweet.
+ `DELETE /tweets/{id}`: Delete a tweet by ID.
+ `GET /tweets/{id}/likes`: Get likes on a tweet by ID.
+ `POST /tweets/{id}/like`: Like a tweet by ID.
+ `DELETE /tweets/{id}/like`: Unlike a tweet by ID.
Feel free to use and modify this template according to your project's needs.
If you have any questions or suggestions, please let me know!</s>
docker compose up --build
The APIs will be exposed to port 9090