This is an API for managing card games. It supports creating card decks, buying cards, shuffling and returning them to the deck.
- Docker
- Docker Compose
$ git clone [email protected]:igorantun/card-games-api.git
$ cd card-games-api
$ cp .env.example .env
$ make dev # Starts development server, with nodemon
$ make start # Starts server
$ make stop # Stops server
$ make kill # Kills containers
$ make restart # Restarts server
$ make clean # Cleans containers and volumes
$ make sh # Opens shell inside api container
$ make test-e2e # Runs end-to-end test scripts
$ make test-unit # Runs unit test scripts
$ make test-coverage # Runs test coverage audit
$ make test # Runs all tests scripts
Request
POST /decks
{
"decks": 2
}
Response
{
"id": "5ec4b190eae60200181db40c",
"remainingCards": 104
}
Request
POST /decks
{
"decks": 1,
"options": {
"without": {
"ranks": ["8", "9", "10"]
}
}
}
Response
{
"id": "5ec4b282eae60200181db40d",
"remainingCards": 40
}
Request
POST /decks/:deckId/buy
{
"cards": 3
}
Response
{
"remainingCards": 37,
"cards": [
{ "rank": "4", "suit": "diamonds" },
{ "rank": "5", "suit": "clubs" },
{ "rank": "7", "suit": "hearts" }
]
}
Request
PUT /decks/:deckId/return
{
"position": "middle",
"cards": [
{ "rank": "7", "suit": "hearts" },
{ "rank": "4", "suit": "diamonds" }
]
}
Response
{
"remainingCards": 39
}
Request
PUT /decks/:deckId/shuffle
Response
{
"remainingCards": 39
}
Released under the MIT License. See the LICENSE file for details.