Skip to content

Commit

Permalink
Merge pull request #249 from BoostryJP/feature/#201
Browse files Browse the repository at this point in the history
feat: add explanation of API documentation
  • Loading branch information
YoshihitoAso committed Dec 16, 2021
2 parents eccab72 + bc410de commit eb3a236
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 14 deletions.
119 changes: 109 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,127 @@
* ibet-SmartContract: version 21.12.0


## Starting and Stopping the Server
Install packages
## Setup

### Prerequisites

- Need to set up a Python runtime environment.
- Need to create the DB on PostgreSQL beforehand.
- By default, the following settings are required.
- User: issuerapi
- Password: issuerapipass
- DB: issuerapidb
- DB for test use: issuerapidb_test
- TokenList contract of the ibet-SmartContract must have been deployed beforehand.

### Install packages

Install python packages with:
```bash
$ pip install -r requirements.txt
```

Create database tables
### Setting environment variables

The main environment variables are as follows.

<table style="border-collapse: collapse" id="env-table">
<tr bgcolor="#000000">
<th style="width: 25%">Variable Name</th>
<th style="width: 10%">Required</th>
<th style="width: 30%">Details</th>
<th>Example</th>
</tr>
<tr>
<td>DATABASE_URL</td>
<td>False</td>
<td nowrap>Database URL</td>
<td>postgresql://issuerapi:issuerapipass@localhost:5432/issuerapidb</td>
</tr>
<tr>
<td>TEST_DATABASE_URL</td>
<td>False</td>
<td nowrap>Test database URL</td>
<td>postgresql://issuerapi:issuerapipass@localhost:5432/issuerapidb</td>
</tr>
<tr>
<td>DATABASE_SCHEMA</td>
<td>False</td>
<td nowrap>Database schema</td>
<td></td>
</tr>
<tr>
<td>WEB3_HTTP_PROVIDER</td>
<td>False</td>
<td nowrap>Web3 provider</td>
<td>http://localhost:8545</td>
</tr>
<tr>
<td>CHAIN_ID</td>
<td>False</td>
<td nowrap>Blockchain network ID</td>
<td>1010032</td>
</tr>
<tr>
<td>TOKEN_LIST_CONTRACT_ADDRESS</td>
<td>True</td>
<td nowrap>TokenList contract address</td>
<td>0x0000000000000000000000000000000000000000</td>
</tr>
<tr>
<td>TZ</td>
<td>False</td>
<td nowrap>Timezone</td>
<td>Asia/Tokyo</td>
</tr>
</table>

Other environment variables that can be set can be found in `config.py`.

### DB migrations

See [migrations/README.md](migrations/README.md).


## Starting the Server

You can start the API server with:
```bash
$ ./bin/run_migration.sh init
$ ./run.sh server (Press CTRL+C to quit)
```

You can start (or stop) the API server with:
```bash
$ ./bin/run_server.sh start(stop)
Open your browser at [http://0.0.0.0:5000](http://0.0.0.0:5000).

You will see the JSON response as:
```json
{"server":"ibet-Prime"}
```

### API docs

#### Swagger UI

Now go to [http://0.0.0.0:5000/docs](http://0.0.0.0:5000/docs).

You will see the automatic interactive API documentation provided by Swagger UI:

![swagger](https://user-images.githubusercontent.com/963333/146362141-da0fc0d2-1518-4041-a274-be2b743966a1.png)


#### ReDoc

And now, go to [http://0.0.0.0:5000/redoc](http://0.0.0.0:5000/redoc).

You will see the alternative automatic documentation provided by ReDoc:

![redoc](https://user-images.githubusercontent.com/963333/146362775-c1ec56fa-f0b0-48a4-8926-75c2b7159c90.png)


## Branching model

<p align='center'>
<img alt="ibet" src="https://user-images.githubusercontent.com/963333/128751565-3268b1e3-185b-4f09-870f-b6d96519eb54.png"/>
</p>
This repository is version controlled using the following flow.

![branching_model](https://user-images.githubusercontent.com/963333/128751565-3268b1e3-185b-4f09-870f-b6d96519eb54.png)

## License

Expand Down
4 changes: 0 additions & 4 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@
BULK_TRANSFER_WORKER_LOT_SIZE = int(os.environ.get("BULK_TRANSFER_WORKER_LOT_SIZE")) \
if os.environ.get("BULK_TRANSFER_WORKER_LOT_SIZE") else 5

# System locale
SYSTEM_LOCALE = [code.strip().upper() for code in os.environ.get("SYSTEM_LOCALE").split(",")] \
if os.environ.get("SYSTEM_LOCALE") else ["JPN"]

# System timezone for REST API
TZ = os.environ.get("TZ") or "Asia/Tokyo"

Expand Down

0 comments on commit eb3a236

Please sign in to comment.