Giter Club home page Giter Club logo

tbupt's Introduction

TBUPT

TBUPT is an implementation of a REST API to simulate a deck of cards

Requirements

  • Go ^1.17 or Docker

Installation

by go package

To install this package, simply go get it:

go get github.com/mocak/tbupt

Makefile Commands

If you downloaded the source files, you can start and test app by commands below.

Command Description
start Starts server
test Runs tests
docker-start Crates and starts docker container
docker-stop Stops and removes docker container
docker-test Runs tests on docker container

Usage

Create Deck

Request:

URL:

POST localhost:3000?cards=AS,5D

Body:

{
    "shuffled": true 
}

Response:

{
    "DeckID": "1812b565-ec8f-44ff-b7bf-b266da50cbeb",
    "Shuffled": true,
    "Remaining": 2
}

Draw Card

URL:

POST localhost:3000/<deck_id>/draw

Body:

{
    "count": 1 
}

Response:

[
    {
        "value": "5",
        "suit": "DIAMONDS",
        "code": "5D"
    }
]

Open Deck

URL:

PUT localhost:3000/<deck_id>/draw

Body:

{
    "count": 1 
}

Response:

{
    "deck_id": "1812b565-ec8f-44ff-b7bf-b266da50cbeb",
    "shuffled": true,
    "remaining": 1,
    "cards": [
        {
            "value": "ACE",
            "suit": "SPADES",
            "code": "AS"
        }
    ]
}

About this Solution

  • Using memory as data storage, sql implementation can be done easily by implementing Storage interfaces.
  • There is validation (and normalization) layer above storage to keep the storage dumb as possible. Multiple similar layers can be added easily by interface chaining if required.
  • Project structure started as MVC and can be converted to other designs (domain driven, package oriented...) when scope started to become clearer.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

GNU

tbupt's People

Contributors

mocak avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.