diff --git a/adapter/README.md b/adapter/README.md index 2d14ce0..b9c05b9 100644 --- a/adapter/README.md +++ b/adapter/README.md @@ -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://:/deal/" + "port": } ``` @@ -96,13 +99,6 @@ Run the local tests: yarn test ``` -Natively run the application (defaults to port 8080): - -To change the default port -```bash -export EA_PORT= -``` - ### Run ```bash @@ -110,14 +106,86 @@ 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:/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:/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: diff --git a/adapter/app.js b/adapter/app.js index b320a6c..7143301 100644 --- a/adapter/app.js +++ b/adapter/app.js @@ -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)