An example of micro-service to be used in cooperation with the score service.
It's made with Express (and TypeScript), and send events through kafka. It uses an in-memory implementation as a database.
This Tic-Tac-Toe is a Back-End implementation of the known Front-End game. It also sends event when a game is won to the score service.
- Install dependencies (recommended with
yarn
). - Copy
.env.example
to.env
. - Start a kafka instance (available with
docker-compose
inside this project). - Start the tic-tac-toe service with
yarn dev
. - Also, start the
score service
.
If you want to learn how we use micro-services in the real world, feel free to have a look at:
- The theory behind micro-services (free articles)
- How we create micro-services in a professional environment (practical course)
- Win a game of tic-tac-toe, connected to the same kafka instance than the score service:
- To get started, initialize the board with a request to
http://localhost:4000/tic-tac-toe/initialize
. - Play to win with X by sending POST requests:
http://localhost:4000/tic-tac-toe/play?step=0&square=0
. - Play to win with X by sending POST requests:
http://localhost:4000/tic-tac-toe/play?step=1&square=8
. - Play to win with X by sending POST requests:
http://localhost:4000/tic-tac-toe/play?step=2&square=1
. - Play to win with X by sending POST requests:
http://localhost:4000/tic-tac-toe/play?step=3&square=7
. - Play to win with X by sending POST requests:
http://localhost:4000/tic-tac-toe/play?step=4&square=2
.
- To get started, initialize the board with a request to
- Send a GET request to the score service
http://localhost:4001/score
to see the list of game won.