-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80f6591
commit d0d2ceb
Showing
1 changed file
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,14 @@ 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). | ||
|
||
### Check npm and node versions | ||
|
||
```sh | ||
npm -version | ||
6.14.16 | ||
|
@@ -23,6 +23,7 @@ npm -version | |
node -v | ||
v14.19.1 | ||
``` | ||
|
||
### Install dependencies | ||
|
||
```sh | ||
|
@@ -34,15 +35,19 @@ To only install resolved dependencies in `package-lock.json`: | |
```sh | ||
npm ci | ||
``` | ||
|
||
### Session DB | ||
|
||
Move to the `SessionDB` folder and run: | ||
|
||
```sh | ||
docker-compose up -d | ||
``` | ||
|
||
### RSK DB | ||
|
||
Move to the `rsk-database` folder, copy your `.env` file in it and then run: | ||
|
||
```sh | ||
docker-compose up -d | ||
``` | ||
|
@@ -53,20 +58,43 @@ For some reason passing `--env-file` argument to docker-compose doesn't seem to | |
|
||
To verify all environment variables, please click [here](./ENV_VARIABLES.md) for environment variables details. | ||
|
||
## Create user with admin permissions to connect without errors to mongoDB | ||
|
||
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" } | ||
] | ||
} | ||
) | ||
``` | ||
|
||
## Using npm to run the application | ||
|
||
If you want to start the API alongside the daemon run: | ||
|
||
```sh | ||
npm start | ||
``` | ||
|
||
If you prefer to execute just the API run: | ||
|
||
```sh | ||
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: | ||
|
||
```sh | ||
npm run start-daemon | ||
``` | ||
|
@@ -83,8 +111,11 @@ To automatically fix such issues: | |
npm run eslint:fix | ||
|
||
``` | ||
|
||
## Deployment | ||
|
||
In the root directory run: | ||
|
||
```shell | ||
docker-compose up | ||
``` | ||
|
@@ -99,7 +130,7 @@ docker-compose up | |
npm run test | ||
``` | ||
|
||
[![LoopBack](https://github.com/strongloop/loopback-next/raw/master/docs/site/imgs/branding/Powered-by-LoopBack-Badge-(blue)[email protected])](http://loopback.io/) | ||
[![LoopBack](<https://github.com/strongloop/loopback-next/raw/master/docs/site/imgs/branding/Powered-by-LoopBack-Badge-(blue)[email protected]>)](http://loopback.io/) | ||
|
||
## Report Security Vulnerabilities | ||
|
||
|