nlevchuk / decks-and-cards

Provides API for creating and opening decks as well as drawing cards

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Test

Description

The small application provides API for creating and opening decks as well as drawing cards.

Technical stack

  1. Typescript
  2. NestJS
  3. PostgreSQL

Installation

  1. Clone the project:
$ git clone https://github.com/nlevchuk/decks-and-cards.git
  1. Go to cloned directory and build the application image:
$ make build

Running the application

$ make up

Stopping the application

$ make down

Usage

Create a new deck

## Create full not suffled deck
curl -X "POST" "http://localhost:3000/decks/create" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "type": "FULL",
  "shuffled": false
}'
## Create short not suffled deck
curl -X "POST" "http://localhost:3000/decks/create" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "type": "SHORT",
  "shuffled": false
}'
## Create full suffled deck
curl -X "POST" "http://localhost:3000/decks/create" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "type": "FULL",
  "shuffled": true
}'
## Create short suffled deck
curl -X "POST" "http://localhost:3000/decks/create" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "type": "SHORT",
  "shuffled": true
}'

Open a deck

curl "http://localhost:3000/decks/open?deckId=<DECK ID>"

Draw cards

curl -X "PUT" "http://localhost:3000/decks/draw-cards" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "deckId": "<DECK ID>",
  "count": "3"
}'

Test

$ make test
$ make test-e2e

About

Provides API for creating and opening decks as well as drawing cards


Languages

Language:TypeScript 94.2%Language:JavaScript 2.6%Language:Makefile 1.5%Language:Shell 1.2%Language:Dockerfile 0.5%