A simple CRUD backend app using Actix-web, Diesel and JWT
- Enter into project directory
- Run
docker-compose -f docker-compose.yml up
curl --location '0.0.0.0:8080/ping' \
--data ''
- Response:
-
200 OK
pong!
-
curl --location '0.0.0.0:8080/auth/register' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "bob@gmail.com",
"password": "bob"
}'
-
Request body:
{ "email": string, "password": string }
-
Response
- 200 OK
{ "message": "ok", "data": "" }
- 400 Bad Request
{ "message": "User already exists", "data": "" }
curl --location '0.0.0.0:8080/auth/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "alice@gmail.com",
"password": "alice"
}'
-
Request body:
{ "email": string, "password": string }
-
Response
- 200 OK
{ "message": "ok", "data": { "token": string // bearer token "token_type": string // token type } }
curl --location --request GET '0.0.0.0:8080/transfer/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3MjExMzY3NjYsImV4cCI6MTcyMTc0MTU2NiwiZW1haWwiOiJhbGljZUBnbWFpbC5jb20iLCJsb2dpbl9zZXNzaW9uIjoiMDM0ZmFkZTAtNTEyMS00ZjkxLWE4OTktMzgzNWQ0YjM3M2EzIn0.XsRYtDr1t6m5_uctXg8jNPNGKopoJvFcW5GQIboRFK4' \
--data-raw '{
"email": "alice@gmail.com"
}'
-
Request body:
{ "email": string, }
-
Response
- 200 OK
{ "message": "ok", "data": { "id": i32, // tx id "from_user": i32, // from user id "to_user": i32, // to user id "amount": i32 // amount transferred } }
curl --location '0.0.0.0:8080/transfer/create' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3MjExMzY3NjYsImV4cCI6MTcyMTc0MTU2NiwiZW1haWwiOiJhbGljZUBnbWFpbC5jb20iLCJsb2dpbl9zZXNzaW9uIjoiMDM0ZmFkZTAtNTEyMS00ZjkxLWE4OTktMzgzNWQ0YjM3M2EzIn0.XsRYtDr1t6m5_uctXg8jNPNGKopoJvFcW5GQIboRFK4' \
--data-raw '{
"from_user":"alice@gmail.com",
"to_user": "bob@gmail.com",
"amount": 5
}'
-
Request body:
{ "from_user": string, "to_user": string, "amount": i32, }
-
Response
- 200 OK
{ "message": "ok", "data": "" }