mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-23 01:55:10 +00:00
Add Jira link to readme
Also adds new transactions endpoint example Signed-off-by: James Taylor <jamest@uk.ibm.com>
This commit is contained in:
parent
432da5defd
commit
3667dd9322
2 changed files with 23 additions and 9 deletions
28
README.md
28
README.md
|
|
@ -1,6 +1,6 @@
|
||||||
# Fabric REST sample
|
# Fabric REST sample
|
||||||
|
|
||||||
Prototype sample REST server to demonstrate good Fabric Node SDK practices
|
Prototype sample REST server to demonstrate good Fabric Node SDK practices for parts of [FAB-18511](https://jira.hyperledger.org/browse/FAB-18511)
|
||||||
|
|
||||||
The primary aim of this sample is to show how to write a long running client application using the Fabric Node SDK
|
The primary aim of this sample is to show how to write a long running client application using the Fabric Node SDK
|
||||||
|
|
||||||
|
|
@ -8,6 +8,8 @@ The REST API is intended to work with the [basic asset transfer example](https:/
|
||||||
|
|
||||||
To install the basic asset transfer chaincode on a local Fabric network, follow the [Using the Fabric test network](https://hyperledger-fabric.readthedocs.io/en/release-2.2/test_network.html) tutorial
|
To install the basic asset transfer chaincode on a local Fabric network, follow the [Using the Fabric test network](https://hyperledger-fabric.readthedocs.io/en/release-2.2/test_network.html) tutorial
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
**Note:** these instructions should work with the release-2.2 branch of `fabric-samples` but later versions require some changes
|
**Note:** these instructions should work with the release-2.2 branch of `fabric-samples` but later versions require some changes
|
||||||
|
|
||||||
To build and start the sample REST server, you'll need to [download and install an LTS version of node](https://nodejs.org/en/download/)
|
To build and start the sample REST server, you'll need to [download and install an LTS version of node](https://nodejs.org/en/download/)
|
||||||
|
|
@ -44,45 +46,53 @@ Start the sample REST server
|
||||||
npm run start:dev
|
npm run start:dev
|
||||||
```
|
```
|
||||||
|
|
||||||
If everything went well, you can now make REST calls!
|
## REST API
|
||||||
|
|
||||||
For example, get all assets...
|
If everything went well, you can now make basic asset transfer REST calls! For example...
|
||||||
|
|
||||||
|
### Get all assets...
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
curl http://localhost:3000/api/assets
|
curl http://localhost:3000/api/assets
|
||||||
```
|
```
|
||||||
|
|
||||||
Check whether an asset exists...
|
### Check whether an asset exists...
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
curl --include --request OPTIONS http://localhost:3000/api/assets/asset7
|
curl --include --request OPTIONS http://localhost:3000/api/assets/asset7
|
||||||
```
|
```
|
||||||
|
|
||||||
Create an asset...
|
### Create an asset...
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
curl --include --header "Content-Type: application/json" --request POST --data '{"id":"asset7","color":"red","size":42,"owner":"Jean","appraisedValue":101}' http://localhost:3000/api/assets
|
curl --include --header "Content-Type: application/json" --request POST --data '{"id":"asset7","color":"red","size":42,"owner":"Jean","appraisedValue":101}' http://localhost:3000/api/assets
|
||||||
```
|
```
|
||||||
|
|
||||||
Read an asset...
|
### Read transaction status...
|
||||||
|
|
||||||
|
```shell
|
||||||
|
curl http://localhost:3000/api/transactions/__transaction_id__
|
||||||
|
```
|
||||||
|
|
||||||
|
### Read an asset...
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
curl http://localhost:3000/api/assets/asset7
|
curl http://localhost:3000/api/assets/asset7
|
||||||
```
|
```
|
||||||
|
|
||||||
Update an asset...
|
### Update an asset...
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
curl --include --header "Content-Type: application/json" --request PUT --data '{"id":"asset7","color":"red","size":11,"owner":"Jean","appraisedValue":101}' http://localhost:3000/api/assets/asset7
|
curl --include --header "Content-Type: application/json" --request PUT --data '{"id":"asset7","color":"red","size":11,"owner":"Jean","appraisedValue":101}' http://localhost:3000/api/assets/asset7
|
||||||
```
|
```
|
||||||
|
|
||||||
Transfer an asset...
|
### Transfer an asset...
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
curl --include --header "Content-Type: application/json" --request PATCH --data '[{"op":"replace","path":"/owner","value":"Ashleigh"}]' http://localhost:3000/api/assets/asset7
|
curl --include --header "Content-Type: application/json" --request PATCH --data '[{"op":"replace","path":"/owner","value":"Ashleigh"}]' http://localhost:3000/api/assets/asset7
|
||||||
```
|
```
|
||||||
|
|
||||||
Delete an asset...
|
### Delete an asset...
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
curl --include --request DELETE http://localhost:3000/api/assets/asset7
|
curl --include --request DELETE http://localhost:3000/api/assets/asset7
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,10 @@ content-type: application/json
|
||||||
"appraisedValue": 101
|
"appraisedValue": 101
|
||||||
}
|
}
|
||||||
|
|
||||||
|
### Read transaction status
|
||||||
|
|
||||||
|
GET {{baseUrl}}/transactions/__transaction_id__ HTTP/1.1
|
||||||
|
|
||||||
### Read asset
|
### Read asset
|
||||||
|
|
||||||
GET {{baseUrl}}/assets/asset7 HTTP/1.1
|
GET {{baseUrl}}/assets/asset7 HTTP/1.1
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue