https://github.com/wpdas/blog-api-rust
This is an API developed with Rust, Rocket & Diesel and was created in order to study Rust. Therefore, the code might not be one of the best since I'm still a noob :D.
https://github.com/wpdas/blog-api-rust
api diesel docker rocket rust
Last synced: about 1 month ago
JSON representation
This is an API developed with Rust, Rocket & Diesel and was created in order to study Rust. Therefore, the code might not be one of the best since I'm still a noob :D.
- Host: GitHub
- URL: https://github.com/wpdas/blog-api-rust
- Owner: wpdas
- Created: 2023-05-22T19:52:08.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-04T00:09:55.000Z (about 3 years ago)
- Last Synced: 2025-03-02T13:14:49.121Z (over 1 year ago)
- Topics: api, diesel, docker, rocket, rust
- Language: Rust
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Blog Api - Rust
This is an API developed with Rust, Rocket & Diesel and was created in order to study Rust. Therefore, the code might not be one of the best since I'm still a noob :D.
## Executing
2 - Install `diesel` if you haven't yet:
```sh
cargo install diesel_cli --no-default-features --features postgres
```
3 - Run the container:
```sh
docker compose up
```
4 - Create the tables:
```sh
diesel migration run
```
5 - Run the app:
```sh
cargo run
```
## Postman
Posting a new content.
**POST:** `http://localhost:8000/post`
Body example:
```json
{
"title": "My First Post",
"body": "The awesome body of my first post! :D"
}
```
Fetching posts.
**GET:** `http://localhost:8000/posts`
## Good to know
If you face the `Id: library not found for -lpq`. Access [this site](https://stackoverflow.com/questions/70313347/ld-library-not-found-for-lpq-when-build-rust-in-macos) to get to know how to fix it.
### Tips
`diesel setup`: Initializes the migrations setup for diesel
`diesel migration generate posts`: Generates posts migration table
`diesel migration run`: Runs migration codes
`diesel migration redo`: It's going to execute the down.sql and up.sql file again in order to redo the migration.