This application generates merkle tree for Comet incentivization campaigns from present participants and their accrued rewards values. And provides verification info about tree entries
- Technologies
- Prerequisites
- Install tools for pre-commit validation
- [Install npm](#install-npm)
- [Install yarn](#install-yarn)
- [Install docker](#install-docker)
- [Install docker-compose](#install-docker-compose)
- Install tools for pre-commit validation
- Running API locally
- Running API on server
- Helpful scripts *root package *API package
- ubuntu - operating system to run server side
- nodejs 20 - javascript server side runtime
- TypeScript - programming language
- NestJS - server side framework
- typeORM - ORM
- postgres - database to store information on server side
- knexjs - to handle postgres database migrations
- docker - to run nodejs API, postgres db
- docker-compose - to manage docker containers
- RabbitMQ - handle pipeline queues
- jest - automated testing of API
- OpenAPI 3.0 - API documentation format
- swagger - to generate HTML documentation
- Intellij - as development tool
- pre-commit - to enforce formatter and other policies before commit
- prettier - to format the code
- eslint - Find and fix problems in your JavaScript code
- config - Handle application configs for specific environment
Linux
sudo apt-get install -y python3 python3-pip
MacOs
brew install python3
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
brew install curl
No space after hash on atx style header
Install npm
Linux
It's required to install node 20 on ubuntu 22.04
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
Or:
sudo apt install nodejs npm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
nvm use 20
MacOs
brew install npm
Install yarn
Linux
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn
Or:
sudo npm install -g yarn
MacOs
brew install yarn
Install docker
Linux
sudo apt-get update
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install -y docker-ce
MacOs
Download desktop app docker
This application will install docker compose plugin
Install docker-compose
Linux
sudo apt-get install docker-compose-plugin
Allow regular user to run docker without sudo
sudo usermod -aG docker ${USER}
sudo usermod -aG www-data ${USER}
sudo chown ${USER} /var/run/docker.sock
You need to reboot or relogin after that
Once rebooted verify that you can run docker commands without sudo.
docker run hello-world
- Install all packages
yarn
- Start docker containers with databases, RabbitMQ.
yarn docker-dev
- Navigate to api package directory, copy and configure
env
file
cd packages/api;
cp ./.env.xmpl ./.env
- Migrate database
yarn migrate
- Start application
yarn start
- Configure PostgreSQL and RabbitMQ services using Dockerfile from corresponding package inside
./packages
or configure them manually - Don't use anything outside
./packages
- it's for local setup - Build and run API service from
./packages/api
lint
- run prettier fix and eslint checkdocker-dev
- build and run local docker containersdocker-dev-down
- shut down local docker container
migrate
- run database migrationsmigrate-dev
- run migrations using dev server envmigrate-prod
- run migrations using prod server envmigrate:make
- create new knex migrationmigrate:down
- rollback last migrationmigrate:down-all
- rollback all migrationsmigrate:up-specific
- apply specific migrationmigrate:down-specific
- apply specific migration