Rest API for game of Minesweeper
The solution follows Interaction-Driven Design (IDD), an iterative approach to software design and development based on Outside-In Development.
- Kotlin 1.3.70
- Gradle 5.6.1 (wrapper provided in sources)
- Mockito-Kotlin 2.2.0
- Kluent 1.61
- Springboot 2.3.4.RELEASE
- Persistence implemented by repositories in-memory
In order to build and run the solution, you need to install:
- JDK 1.8 (recommended installation via SDKMAN!)
$ ./gradlew clean build
POST /admin/users
{
"userName": "diegap"
}
Response 201 CREATED
POST /users/:userName/boards
:userName string that defines the userName
{
"rows": 4,
"cols": 4,
"mines": 1,
"user": {
"userName": "diegap"
}
}
Response 201 CREATED
Response 404 NOT FOUND
If the userName does not exist an http status 404 is returned.
GET /admin/boards
{
"boardIds": [
"669a0b34-c8a8-4e30-b9da-7dd2a7d6e58f",
"ccaead72-80ca-4517-bd1b-4a54b112cc75"
]
}
Response 200 OK
PUT /users/:userName/boards/:boardId/status
:userName string that defines the userName
:boardId string that defines the boardId
{
"status": "PAUSE"
}
Response 200 OK
Response 400 BAD REQUEST
The allowed values for status are "PAUSE" and "RESUME".
PUT /users/:userName/boards/:boardId/cells
:userName string that defines the userName
:boardId string that defines the boardId
{
"x": 0,
"y": 2,
"command": "REVEAL"
}
Response 200 OK
Response 400 BAD REQUEST
The allowed values for command are "REVEAL", "FLAG", "UNFLAG", "QUESTION" and "UNQUESTION".
Have in mind that a cell marked as "FLAG" or "QUESTION" cannot be revealed without being "UNFLAG" or "UNQUESTION" first.
You can play with the latest deployed version at DEMO