This is a WIP and should only be used as is.
This is an API made in Rust 🦀 using Rocket 🚀 and postgres
The idea is to use this API as a game service. Client applications should call a "play game" endpoint with appropriate query paths. The response should return whether a game has been won or lost and also what reward for the win. These entries should be saved in the postgres database in table for played games.
Furthermore, there will be a CRUD for games, rewards, and played games, so that an external CMS could access this and make changes to the service.
TODO: Write a script to init db with the sql_dump file.
TODO: Could deploy an instance on Digital Ocean (that could be the cheapest option)
Run cargo test
to run all the tests.
You can import the Insomnia documentation json file into Insomnia.
Or use the cURL commands defined below.
Remember to have postgres installed and running.
Note: You can generate API documentation like Swagger with insomnia-documenter.
curl --request GET \
--url http://localhost:8000/api/game/play/1/23284323
curl --request POST \
--url http://localhost:8000/api/game \
--header 'Content-Type: application/json' \
--data '{
"title": "nfjdnf",
"body": "body thingyfdjvcd",
"daily_prices": 100,
"winning_chance": 5,
"images": [
{
"image": "https://cataas.com/cat"
},
{
"image": "https://cataas.com/cat"
}
]
}'
curl --request GET \
--url http://localhost:8000/api/game/
curl --request GET \
--url http://localhost:8000/api/game/2