Skip to content

stevenpmcfarlane/tictactoe-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tic Tac Toe API

Endpoints

POST /lobbies
GET /lobbies/:id
POST /lobbies/:id/players

POST /games
GET /games/:id
POST /games/:id/players

GET /games/:id/state
PATCH /games/:id/state

POST /lobbies

Create a lobby

Response

{
  "id": "uuid"
}

POST /lobbies/:id/players

Join lobby

Request

{
  "playerName": "string"
}

Response

{
  "playerId": "uuid"
}

GET /lobbies/:id

Response

{
  "id": "uuid",
  "name": "string",
  "currentGameId": "uuid",
  "players": {
    <playerId>: {
      "id": "uuid",
      "name": "string",
      "score": "integer"
    }, {...}
  },
  "gamesPlayed": ["uuid"]
}

POST /games

Starts a new game

Request

{
  "playerId": "uuid",
  "lobbyId": "uuid"
}

Response

{
  "id": "uuid"
}

GET /games/:id

Response

{
  "id": "uuid",
  "lobbyId": "uuid",
  "playerX": "uuid",
  "playerO": "uuid",
  "startDate": "datetime"
}

POST /games/:id/players

Request

{
  "playerId": "uuid"
}

GET /games/:id/state

Response

{
  "id": "uuid",
  "controller": "uuid", // playerId of person whose turn it is
  "concluded": "boolean",
  "winner": "uuid",
  "board": [
    ["", "", ""],
    ["", "", ""],
    ["", "", ""]
  ]
}

PATCH /games/:id/state

Update player moves

About

Tic Tac Toe backend

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published