Commit graph

61 commits

Author SHA1 Message Date
Arnaud J Le Hors
75bdde97cd
Improve REST sample README (#647)
Add that one needs to have the ledger initialized for the sample to
work.

Signed-off-by: Arnaud J Le Hors <lehors@us.ibm.com>
2022-02-17 16:55:26 +00:00
dependabot[bot]
6739199db2
Bump follow-redirects in /asset-transfer-basic/rest-api-typescript (#643)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.7 to 1.14.8.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.7...v1.14.8)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-15 15:36:23 +01:00
James Taylor
e7074ba941
Update REST sample with Redis password (#629)
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2022-02-04 14:27:40 +00:00
James Taylor
5edae7c444
Update samples to use published fabric-rest-sample (#626)
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2022-02-03 12:15:29 -05:00
James Taylor
980da6f8aa
Add REST sample to CI (#611)
Build, test, and publish the REST server sample

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2022-02-02 16:34:08 +00:00
James Taylor
5d3cc66c25
Convert comments to tsdoc in REST sample (#606)
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2022-02-01 17:12:07 +01:00
dependabot[bot]
84c101fb8a
Bump follow-redirects in /asset-transfer-basic/rest-api-typescript (#584)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.6 to 1.14.7.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.6...v1.14.7)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-19 14:36:23 +01:00
James Taylor
887e4a3578
Update REST sample readme (#575)
Move signposts to sample source files from index.ts to the readme and reinforce the key aspects of the sample

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2022-01-12 10:38:44 +00:00
James Taylor
af2f6e005c Prepare REST sample for fabric-samples repository
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-15 14:25:09 +00:00
James Taylor
fce803af24 Add jobs spec tests
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-15 14:24:58 +00:00
James Taylor
dfe79f7fb4 Add comments to jobs.ts
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-15 14:24:34 +00:00
James Taylor
5447e3534d Add node, and npm version requirements
Match the versions required in asset-transfer-basic/application-typescript

Also update to latest version of fabric-network

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
711f1f560b Use app.locals to store contracts and jobq
“The app.locals object has properties that are local variables within the application.”

…which looks like a better option than app.get and app.set for app settings.

Also passes app to the initJobQueueWorker function for consistency.

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
66199000ca Fix lint errors
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
5d92abc52d Clarify retry logic
Improve the separation between Fabric logic and the job queue implementation details

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
b0256a57b5 Signpost configuration details
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
5a32d803c9 Use user credentials
Use User1 certificate and private key for org1 and org2 instead of Admin credentials

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
2d7da062d8 Update Dockerfile
Fabric is on alpine 3.14 so update the sample to match

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
b1bc6663b8 Update readme
Minor changes for Fabric 2.4 and the main branch of fabric-samples

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:24 +00:00
James Taylor
ad3fd7e832 Update retry logic
Previously transactions were only retried after being successfully endorsed, and always with the same transaction ID

Transactions will now be added to a queue for processing and will also be retried if endorsement fails (with a different transaction id for invalid transactions)

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
0456a9e94c Move error related functions to errors.ts
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
fd269237d4 Add comments to fabric.ts
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
00a2dea50b Add block event listener config
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
f1a9fea77d Fix lint errors
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
e6738818e5 Update readmes
Move usage instructions to the node sample directory and add overview/next steps
to top level readme

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:23 +00:00
sapthasurendran
9aec7ffd2a Clear Transaction when no contract found
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:23 +00:00
James Taylor
bf91df7ef3 Update transaction retry to use correct user
Also improves test coverage

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:21 +00:00
James Taylor
82b1249f4e Improve Docker support
- default command should be start, rather than start:dev in the docker image
- added a multistage build
- fixed node-gyp error
- removed dev dependencies
- added a start:dotenv script to support a .env file in production (may be useful for
k8s later)
- updated Readme and generateEnv script to simplify the setup
- updated external network in docker-compose.yaml to match the test network

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:21 +00:00
James Taylor
5d1adddd03 Refactor health routes in to separate file
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:21 +00:00
James Taylor
45683b2a1a Simplify fabric code
Attempt to make fabric code easier to document

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:21 +00:00
James Taylor
862080773e Initial API tests
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:21 +00:00
sapthasurendran
6477333743 redis mock class
code cleanup

created fabric.spec

redis testcases and additional checks

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:21 +00:00
James Taylor
f904adbf6f Add config spec tests
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:20 +00:00
James Taylor
e81a7a8b46 Update port number config
Discovered that env-var will validate port numbers, which is nice

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:20 +00:00
sapthasurendran
5bea58e501 retry condition moved to startretryloop
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:20 +00:00
sapthasurendran
b8509490ad retry count check
build err fix

retry condition testcase

retryCount to maxRetryCount

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:18 +00:00
sapthasurendran
73049e0153 docker file for app
readme update for docker

added dockerignore

added dumb-init

env var added to compose

readme update

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:17 +00:00
James Taylor
4277f4a68f Fix dist output
The jest.config.ts file was causing unintended changes to the dist folder

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:15 +00:00
James Taylor
9f48a42418 Initial test framework
Add Jest test framework

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:15 +00:00
sapthasurendran
9ae66c76da switch gateway based on user org
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

initialized fabric components to global app const

getcontractforOrg for transaction router

removed org and reused identityOrg1

env.sample file update

liveness api update

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:15 +00:00
James Taylor
05f7026e58 Update api key header
Use more common X-Api-Key header with no prefix

Also updates Unauthorized response to include a json error body
and simplifies working with new API key via curl and the vscode
rest client

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:31:13 +00:00
sapthasurendran
c3a34ef559 apikey auth for Org1
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

removed auth check from live,ready apis..

code format

http file changes for apikey

comments for getting api key

readme update for apikey usage

replaced -H with --header

apikey config made mandatory

fix linting

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:13 +00:00
sapthasurendran
d4318c381a liveness
used fabric protos insted of blockdecoder

changed import statement

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

revert back eslintrc

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

function name change

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

format changes

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:12 +00:00
sapthasurendran
fc769cfcb0 event handler strategy changes
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:11 +00:00
sapthasurendran
31b08b9151 removed txn commit event handler
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:10 +00:00
sapthasurendran
5d6e916436 changed getContract arg
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:09 +00:00
sapthasurendran
550e95f091 Added blockEvent handler
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:05 +00:00
sapthasurendran
804f4a6468 added getNetwork functionality
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2021-12-14 14:31:00 +00:00
James Taylor
19e28d817b Fix retry
Adding multiple contracts had broken the retry loop

Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:57 +00:00
James Taylor
432da5defd Add get transaction endpoint
Signed-off-by: James Taylor <jamest@uk.ibm.com>
2021-12-14 14:14:56 +00:00