A RESTful API with Chess logic made from scratch using TypeScript + Express.JS.
GET -- /api -- Status route, can be used for measuring ping. 
GET -- /api/games/new -- Creates and returns a new game. 
GET -- /api/games/:gameID -- Returns the game info of the specified game ID. 
GET -- /api/games/:gameID/moves/:pieceUID -- Returns the valid moves (encoded) of the specified piece. 
POST -- /api/games/:gameID/moves/:pieceUID -- Moves the specified piece (pieceUID parameter in URL) to a specified position (moveTo property in JSON body)
GET /api (Returns the status of the API)
None
http code content-type response 200application/json{"status": "success", "timestamp": 1729072605904}
GET /api/games/new (Creates a new game and returns the game's information.)
None
http code content-type response 200application/json{"status": "success", "game": {...}
GET /api/games/:gameID (Returns the game information of the specified game ID.)
name type data type description gameID required number The unique ID of the game. 
http code content-type response 200application/json{"status": "success", timestamp: 1729072605904, data: {...}, errors: []}404text/html<html><body>NOT FOUND</body></html>
GET /api/games/:gameID/moves/:pieceUID (Returns valid moves of the specified piece.)
name type data type description gameID required number The unique ID of the game. pieceUID required number The unique ID of the piece. 
http code content-type response 200application/json{"status": "success", "moves": [...] }404application/json{"status": "failed", "message": "No piece exists for the specified UID." }404text/html<html><body>NOT FOUND</body></html>501application/json{"status": "failed", "message": "An error occured while generating moves." }
POST /api/games/:gameID/moves/:pieceUID (Moves the specified piece in the specified game to the specified position. (don't mind the alliteration)
none
property type required applies to information moveTo string yes All piecesThe position where the piece should move to.killPos string no All piecesThe position of the piece that is to be captured; This value is different from "moveTo" property only in case of an en passant.promoteTo string no PawnThe piece that the pawn should be promoted to; Valid values are: "r, n, q, b" - Rook, Knight, Queen, and Bishop respectively.castleTarget string no KingThe position of the rook that is to be castled with.
http code content-type response 200application/json{"status": "success", game: {...}}400application/json{"status": "failed", "message": "Invalid move." }400application/json{"status": "failed", "message": "It is not your turn." }404text/html<html><body>NOT FOUND</body></html>404application/json{"status": "failed", "message": "No piece exists for the specified UID." }501application/json{"status": "failed", "message": "An error occured while trying to move the specified piece." }
- Navigate to project's base directory from a terminal.
- Run yarn installornpm install.
- Run yarn startornpm start.- The application will start listening for requests at port 3000.