Skip to content

An example of micro-service with NodeJS/ExpressJS, TypeScript, and Kafka

Notifications You must be signed in to change notification settings

scalablebackend/tic-tac-toe-service

Repository files navigation

Micro-Service: Tic-Tac-Toe

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.

Installation

  • 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.

Learn micro-services in-depth

If you want to learn how we use micro-services in the real world, feel free to have a look at:

Usage

  • 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.
  • Send a GET request to the score service http://localhost:4001/score to see the list of game won.

About

An example of micro-service with NodeJS/ExpressJS, TypeScript, and Kafka

Topics

Resources

Stars

Watchers

Forks