This project is a benchmarking ranking API developed with Node.js, Express, TypeScript, and Prisma.
Make sure you have Node.js installed on your machine.
-
Clone this repository;
-
Navigate to the project directory;
-
Install the dependencies:
yarn
In the .env file, assign a base64-encoded 32-byte (AES-256) value to API_KEY. Ensure that this key is the same as the one used in the client applications.
-
Make sure you have a database configured and update the
.envfile with your database URL. Example:DATABASE_URL="mysql://user:password@localhost:3306/database-name" -
Run the Prisma migration to configure the database:
npx prisma db push
You can run this project in production using Docker.
-
Start the MySQL database container:
docker compose up db
You can configure the container using environment variables in the
.envfile:DOCKER_MYSQL_ROOT_PASSWORD: Password for the root user (default:root)DOCKER_MYSQL_USER: Database user (default:user)DOCKER_DB_VOLUME_PATH: Path for the database volume (default: named volumeranking_db_data)DOCKER_DB_BACKUP_FILE_TO_CONSUME: Path to a backup file to initialize the database with, if any. When provided, the database will start with the backup data.ENABLE_BACKUP: If the database container should do backup in the BACKUP_PATHDOCKER_DB_BACKUP_PATH: Path to store the backup if ENABLE_BACKUP is true (default:./backup)`BACKUP_INTERVAL: Interval to do the backup (default: 86400 seconds, or one day)
-
Start the API container:
docker compose up app
Environment variables you can set in
.env:DOCKER_BACK_PORT_EXPOSED: Port on the host machine to access the API (default:3030)PORT: Port where the API will run inside the container (and outside, if run without Docker) (default:3030)