This is the API component for 2-Way-Peg solution.
The solution will be a web interface, which integrates with a Rest API (this application), which in turn communicates with internal services such as the blockchain node and databases. In addition, a daemon/worker will be created that will be responsible for obtaining data from the blockchain and changing the status of the transaction.
The 2wp-api application will run on 3000 port.
Include a .env file with the required environment variables listed in .env.test file (you can copy that file).
NOTE: You must have access to a Blockbook server running in the required network and provide its url in the
.envfile. If you want to setup locally please read the instructions.
Install and run the use command to get the needed npm and node version
nvm useTo only install resolved dependencies in package-lock.json:
npm ciMove to the SessionDB folder and run:
docker-compose up -dMove to the rsk-database folder, copy your .env file in it and then run:
docker-compose up -dFor some reason passing --env-file argument to docker-compose doesn't seem to be working fine. That's why we need to copy the .env file here too.
To verify all environment variables, please click here for environment variables details.
To connect without authentication errors to mongodb, in root directory run:
$ docker exec -it 2wp-rsk-mongo-database bash
$ mongosh
$ use rsk
$ db.createUser(
{
user: "api-user",
pwd: "pwd",
roles: [
{ role: "userAdmin" , db:"rsk" }
]
}
)
If you want to start the API alongside the daemon run:
npm startIf you prefer to execute just the API run:
npm run start-apiOpen http://127.0.0.1:3000 in your browser to discover the API capabilities
If you prefer to execute just the daemon run:
npm run start-daemonnpm run eslintTo automatically fix such issues:
npm run eslint:fix
npm ci
npm run unit-test
npm run eslint
npm run only-coverage
In the root directory run:
docker-compose upnpm run openapi-spec: Generate OpenAPI spec into a file
To report a vulnerability, please use the vulnerability reporting guideline for details on how to do it.
-@2x.png)