This repository contains code that powers chess.io's gameplay, user authentication, and analytics. It provides an API web clients can use to perform these actions. Written in NodeJS with the ExpressJS framework, PostgreSQL for player data, and Redis for real-time game state.
All endpoints aside from the base must be prefixed with /v1
before requests are handled.
Method | Endpoint | Requires Auth | Description |
---|---|---|---|
GET | / |
False | Base endpoint. |
GET | /v1/health |
False | Health checks, returns a 200 if the server is up. |
POST | /v1/auth/register |
False | Registers a new user and generates an authentication token if successful. |
POST | /v1/auth/login |
False | Logs in a user after validating credentials, returns an authentication token. |
POST | /v1/auth/reset-password |
False | Resets user password after verifying username and secret question. |
POST | /v1/auth/logout |
True | Attempts to log a user out after verifying their authorization token. Denies the request if the token is invalid / blacklisted. |
POST | /v1/challenge/create |
True | Creates a pending chess challenge, expires in 30 mins if unused. |
POST | /v1/challenge/accept/:id |
True | Accepts and assigns the opponent to the challenge specified by the id. |
GET | /v1/game/state/:id |
True | Returns a payload containing the current game position and other metadata. |
GET | /v1/game/challenge/:id |
True | Returns true if a chess challenge has started a game. |
To develop / test the endpoints locally, clone the repo then follow the steps outlined below.
git clone https://github.com/dev-xero/chess.io-backend.git chess-backend
yarn prisma generate
.migrations.sh
.server.sh
.yarn start:prod
.clean.sh
script.