Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

630 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quality Gate Status

OpenSSF Scorecard

2wp-api

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.

Development Mode

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 .env file. If you want to setup locally please read the instructions.

Check npm and node versions

Install and run the use command to get the needed npm and node version

nvm use

Install dependencies

To only install resolved dependencies in package-lock.json:

npm ci

Database (MongoDB)

See Docker Deployment below to start MongoDB (and optionally the API) via docker-compose.

Environment Variables

To verify all environment variables, please click here for environment variables details.

Connecting to MongoDB

The database user is created automatically on the container's first startup from your .env's RSK_DB_CONNECTION_* values (see Docker Configuration Summary below and docs/setup.md for the manual/edge-case fallback).

Using npm to run the application

If you want to start the API alongside the daemon run:

npm start

If you prefer to execute just the API run:

npm run start-api

Open 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-daemon

Endpoints / API Reference

The running application serves an interactive REST Explorer at /explorer and an OpenAPI spec at /openapi.json (both disabled when NODE_ENV=production). For the full route table plus the data-access extension point, see docs/api.md and docs/data-services.md.

Testing

npm run unit-test        # dist/__tests__/**/*.unit.js
npm run acceptance-test  # dist/__tests__/**/*.acceptance.js
npm run test:all         # both suites
npm run coverage         # nyc report (after a test run)

Fix code style and formatting issues

npm run eslint

To automatically fix such issues:

npm run eslint:fix

Build & test project

npm ci
npm run unit-test
npm run eslint
npm run only-coverage

Docker Deployment

The project includes Docker Compose configuration for running both the API and MongoDB database together.

Docker Configuration Summary

  • API Service: Runs on port 3000, connects to MongoDB using service name pp-api-db
  • MongoDB Service: Runs on ports 27017-27019, automatically initializes with user and database from environment variables

Start Database Only (Development)

To start only the MongoDB database for local development:

# Start MongoDB container
docker-compose up -d pp-api-db

# View logs
docker-compose logs -f pp-api-db

The database will be accessible at localhost:27017. Make sure your .env file has RSK_DB_CONNECTION_HOST=localhost for local development.

Start Full API Stack

To start both the API and MongoDB together:

# Start all services
docker-compose up -d

The API will be accessible at http://localhost:3000 and will automatically connect to MongoDB using the Docker service name.

Note: When running in Docker, the API uses pp-api-db as the MongoDB host (configured in docker-compose.yml). For local development without Docker, use localhost.

Other useful commands

  • npm run openapi-spec: Generate OpenAPI spec into a file

Documentation

See docs/ for setup details beyond this README (setup.md), the full routes table and live API docs (api.md), and the GenericDataService storage extension point and its MongoDB implementations (data-services.md).

LoopBack

Report Security Vulnerabilities

To report a vulnerability, please use the vulnerability reporting guideline for details on how to do it.

About

No description, website, or topics provided.

Resources

Security policy

Stars

9 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages