This example demonstates a nodejs server which uses corda rpc-3.1 library running in GraalVM. The nodejs server serves APIs to create IOU, fetch IOUs similar to the cordapp-example
- Follow the official GraalVM documentation on how to setup the Graal for linux or osX.
- To learn more about GraalVM refer to the Mike Hearn's blog
- Run the cordapp-example nodes
- Make sure that the
nodeConfig.json
file matches the settings of a running node - Run
./gradlew printClassPath
once to make sure everything is downloaded. You should see a big classpath be printed. - Run
npm install
from root directory of the project to install express and body-parser npm modules. - Run
node --jvm --jvm.cp=$( ./gradlew -q printClasspath ) server.js
- Output will look like:
PartyA Node.js server listening on port 3000
If you get the following error when starting the server, you need to install GraalVM:
node: bad option: --jvm
node: bad option: --jvm.cp=
curl -d '{"iouValue":10, "otherPartyOrgName":"PartyB","otherPartyOrgCountry":"New York", "otherPartyOrgLocality":"US"}' -H "Content-Type: application/json" -X POST http://localhost:3000/api/example/create-iou
curl http://localhost:3000/api/example/ious
Other endpoints
- GET /api/example/me
- GET /api/example/peers