diff --git a/server/app.js b/server/app.js index 107845d..42b2b1c 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("/get_from_bc", (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