8000 GitHub - ivan-sabo/tic-tac-toe
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ivan-sabo/tic-tac-toe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tic-tac-toe

This is an API backend project for tic-tac-toe game :)

Requirements: golang 1.18 docker docker-compose

To run the project you will have to first run "docker-compose up -d" inside root folder. This will run docker container with required database. As you could see in docker-compose.yaml, volume is not used for persistant storage.

Next, you will have to run "go run ./cmd/admin/migrate.go". This will run necessary migration and create a database table inside your docker container.

Finally, run "go run ./cmd/api/main.go". This will fire up game and expose api on localhost:8080/v1/games.

Supported endpoints:

GET /v1/games
POST /v1/games          - expects either an empty body, or first move. This is an example of first move request body: {"board":"X--------"}
GET /v1/games/{uuid}
PUT /v1/games/{uuid}

Todo:

- write unit tests
- make database and api configurable (ports, username, password, etc)
- add strategy pattern for AI player algorithms
- add dependency injection

The only part of code that is not written by me resides inside main.go, it's practically an example how to use graceful shutdown using gin framework:

https://github.com/gin-gonic/examples/blob/master/graceful-shutdown/graceful-shutdown/notify-with-context/server.go

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0