A simple todo app using rust.
Make sure you have docker installed on your machine.
- Copy
.env.example
to.env
. Feel free to make changes if you have to. - Run
docker compose up -d
.
You now have the app up and running at http://localhost:8080
.
Make sure you have docker and cargo installed on your machine.
- Copy
.env.example
to.env
. Feel free to make changes if you have to. - Run this:
docker compose up -d db dbviewer
cargo install sqlx-cli --features postgres
cargo sqlx migrate run
bash -c 'source .env && DATABASE_URL=$DATABASE_URL cargo run'
There are 2 endpoints in the app.
GET /todos
: to get all todos in the database.POST /todos
: to add a todo. The body should at least containtitle
anddescription
.
This is how to get all todos using curl:
curl http://localhost:8080/todos
This is how to add a todo using curl:
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"title": "My Todo",
"description": "This is a sample todo description."
}' \
http://localhost:8080/todos
You can open http://localhost:3000
. To directly query the db from sqlpad
(Don't forget to choose the connection in the upper left corner or you won't see anything).