From 4efe6eb55cc2e842ad895f7da702d78ed0685f2c Mon Sep 17 00:00:00 2001 From: Ashish0070 Date: Thu, 2 Sep 2021 10:29:26 +0530 Subject: [PATCH 1/2] communication with hospital server --- server/app.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/server/app.js b/server/app.js index 107845d..01d119c 100644 --- a/server/app.js +++ b/server/app.js @@ -3,9 +3,10 @@ const fs = require('fs') const path = require('path') const solanaWeb3 = require('@solana/web3.js') const app = express() -const port = 3000 +const port = 5000 const borsh = require('borsh') const crypto = require('crypto') +const { response } = require('express') const programPath = path.resolve(__dirname, '../smartContract/dist/program') const programKeypairPath = path.join(programPath, 'helloworld-keypair.json') @@ -46,6 +47,27 @@ app.listen(port, () => { testContract() }) +app.post("/store_on_bc", (request, response) => { + const json = request.body + const report_id = json['report_id'] + const hospital_id = json['hospital_id'] + const hashed_document = json['hashed_document'] + // send transaction - store hashed doc on BC + + + response.sendStatus(200) +}) + +app.post("/", (request, response) => { + const json = request.body + const report_id = json['report_id'] + const hospital_id = json['hospital_id'] + //get hashed document from BC + let hashed_document + + response.send({'result': hashed_document}) +}) + async function testContract() { console.log('Starting a solana connection') programId = (await createKeypairFromFile(programKeypairPath)).publicKey From 6806b26b32d82a293bd51282b58b288129800203 Mon Sep 17 00:00:00 2001 From: Ashish0070 Date: Thu, 2 Sep 2021 10:31:29 +0530 Subject: [PATCH 2/2] communication with hospital server --- server/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/app.js b/server/app.js index 01d119c..42b2b1c 100644 --- a/server/app.js +++ b/server/app.js @@ -58,7 +58,7 @@ app.post("/store_on_bc", (request, response) => { response.sendStatus(200) }) -app.post("/", (request, response) => { +app.post("/get_from_bc", (request, response) => { const json = request.body const report_id = json['report_id'] const hospital_id = json['hospital_id']