Skip to content

Commit

Permalink
Merge pull request #53 from Danny-Ngg/main
Browse files Browse the repository at this point in the history
Update API and Readme
  • Loading branch information
Danny-Ngg authored Mar 2, 2022
2 parents 6572da3 + c5d9f35 commit a34d143
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 11 deletions.
88 changes: 78 additions & 10 deletions adapter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,13 @@ Install dependencies:
```bash
yarn
```
Default running port is 8080. By changing "port", you may set the new running port
Update hostname and port pointing to flink back-end in file adapter/config.json:

```bash
{
"url" : "http://<host>:<port>/deal/"
"port": <port>
}

```
Expand All @@ -96,28 +99,93 @@ Run the local tests:
yarn test
```

Natively run the application (defaults to port 8080):

To change the default port
```bash
export EA_PORT=<port>
```

### Run

```bash
yarn start
```

## Call the external adapter/API server
Flink is supporting both GET and POST api calls

POST /deal
```bash
curl -X POST -H "content-type:application/json" "http://localhost:<port>/deal" --data '{ "id": 0, "data": { "deal":"58160", "network":"filecoin_mainnet"} }'
```
Response format for POST
```bash
curl -X POST -H "content-type:application/json" "http://localhost:8080/" --data '{ "id": 0, "data": { "deal":"58160", "network":"filecoin_mainnet"} }'
{
"jobRunID": 0,
"data": {
"status": "success",
"data": {
"deal": {
"deal_id": 58160,
"deal_cid": "bafy2bzacedqgkcc6helnjwk267fmfjjvvldhhypseskixrtxkfok5rzowev7o",
"message_cid": "",
"height": 23211,
"piece_cid": "baga6ea4seaqjvvaedq7tj2c6t4c3a5mknjvzfnnuil6yh7u7n6nrg22moggr6gy",
"verified_deal": false,
"storage_price_per_epoch": 1,
"signature": "",
"signature_type": "",
"created_at": 1599002730,
"piece_size": "",
"start_height": 28969,
"end_height": 733548,
"client": "",
"client_collateral_format": "000000000000000000",
"provider": "f01278",
"provider_tag": "",
"verified_provider": 0,
"provider_collateral_format": "000000000000000000",
"status": 0,
"network_name": "filecoin_mainnet",
"storage_price": 704579
}
},
"result": {}
},
"result": {},
"statusCode": 200
}
```
GET /deal/{deal_id}?network=filecoin_mainnet
```bash
curl -X GET "http://localhost:8080?deal=58160&network=filecoin_mainnet"
curl -X GET "http://localhost:<port>/deal/58160?network=filecoin_mainnet"
```
Response format for GET
```bash
{
"status": "success",
"data": {
"deal": {
"deal_id": 58160,
"deal_cid": "bafy2bzacedqgkcc6helnjwk267fmfjjvvldhhypseskixrtxkfok5rzowev7o",
"message_cid": "",
"height": 23211,
"piece_cid": "baga6ea4seaqjvvaedq7tj2c6t4c3a5mknjvzfnnuil6yh7u7n6nrg22moggr6gy",
"verified_deal": false,
"storage_price_per_epoch": 1,
"signature": "",
"signature_type": "",
"created_at": 1599002730,
"piece_size": "",
"start_height": 28969,
"end_height": 733548,
"client": "",
"client_collateral_format": "000000000000000000",
"provider": "f01278",
"provider_tag": "",
"verified_provider": 0,
"provider_collateral_format": "000000000000000000",
"status": 0,
"network_name": "filecoin_mainnet",
"storage_price": 704579
}
}
}
```

## Docker

If you wish to use Docker to run the adapter, you can build the image by running the following command:
Expand Down
2 changes: 1 addition & 1 deletion adapter/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const port = portConfig || 8080

app.use(bodyParser.json())

app.post('/', (req, res) => {
app.post('/deal', (req, res) => {
console.log('POST Data: ', req.body)
createRequest('post', req.body, (status, result) => {
console.log('Result: ', result)
Expand Down

0 comments on commit a34d143

Please sign in to comment.