Minesweeper API
This is a basic API for the game Minesweeper. Written in Golang and using Redis for storage.
For build it locally, you might need Redis installed locally, otherwise, use docker-compose to run via make command,
or directly run with docker-compose
Using golang and remote Redis. (check out the redis availability)
Run the tests
go test -v ./...
Build the API
go build -o ms-api cmd/main.go
Run the API
./ms-api
With Docker compose
up all the containers, run locally in 8080 port
make up
or
docker-compose up
down all the containers
make down
or
docker-compose down --remove-orphans
check status
docker-compose ps
Check if API is up and running (server response: 200)
curl -X GET \
http://localhost:8080/heartbeat
Create a new user (server response: 201)
curl -X POST \
http://localhost:8080/users \
-d '{
"username": "tomasito"
}'
Create a game (need a username already created, Server response: 201 otherwise 400 will be sent to the client)
curl -X POST \
http://localhost:8080/games \
-d '{
"name": "game1",
"rows": 10,
"cols": 10,
"mines": 10,
"username": "tomasito"
}'
Start a game (Server response: 200, if the game or username are not present, 400 will be sent to the client)
curl -X POST localhost:8080/games/game1/users/tomasito
Play by clicking, marking or flagging (click_type might be click, mark or flag, Server response: 200)
curl -X POST \
http://localhost:8080/games/game1/users/tomasito/click \
-d '{
"row": 1,
"col": 3,
"click_type": "click"
}'
Demo URL in development
https://tomas-ms-api-second.herokuapp.com/heartbeat