It is a small game that highlights chessboard cells corresponding to the possible positions that the piece knight on the chess can stay after playing 2 times consecutively.
It consists of a backend server in NodeJs with Express and a frontend client in ReactJs.
- Client: React
- Server: NodeJs (Typescript)
Below you can find 2 ways to run this project.
# Clone repository
# Start mongo on docker (optional)
make mongo
# Build front and run server on docker
make run-docker
# Server will be running on http://localhost:3000
# Clone repository
# Run mongo at port 27018 (optional)
# Download dependencies for client and server
sudo npm i -g typescript
sudo npm i -g ts-node
make install
# Generate build files for client (./build folder)
make build-front
# Run server (it will also serve the ./build folder)
make run
# Server will be running on http://localhost:3000
The business logic inside server/services is tested within ./tests folder using Mocha and Chai:
make test
Run linters on server and client
make lint
Run dependencies audit
make audit
All available REST API documentation exposed by the project was documented using the OpenAPI standard.
To view this documentation locally use the following command:
make run-swagger
To deploy this project to Heroku as one app only, it the server will be serving the static content of the ./client/build folder. For that, the way I figured to make it work it is to commit the ./client/build folder to git.
# Build front needs to be done locally
make build-front
# And on .gitignore ./client/build folder needs to be removed
# So the static files are commited when sent to heroku/dokku
After this the normal procedure for a Heroku app deploy can be done.
PS.: A better way would be to run server as a separate Heroku app and another app with NGINX image to run the web server for the static files of the frontend. However it would need to git repositories for it.
After clicking the square in the chessboard, a GET request passing the position in algebric format (e.g.:A8, D5, H1) as param in the URL. The string of the position will be checked in the server according to a regex, and if it passes then the calculation of the possible knight moves for 2 turns in advance are made and the result with an array with all the positions in algebric format is sent to the client that highlights the corresponding cells that are already mapped.