From 59c31a6dc9a3ebf0abf52ce50f444f4855219004 Mon Sep 17 00:00:00 2001 From: Gabriel Cardona Date: Fri, 29 Jun 2018 18:28:09 +0900 Subject: [PATCH] Return json mime type. --- package.json | 2 +- routes/blockchain.js | 10 +++++----- routes/generating.js | 2 +- routes/mining.js | 4 ++-- routes/rawtransactions.js | 2 +- test/blockchain.js | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index da780e07..98e81609 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rest-cloud", - "version": "1.0.2", + "version": "1.1.0", "private": true, "scripts": { "start": "node ./bin/www", diff --git a/routes/blockchain.js b/routes/blockchain.js index fd6e2610..e553a92d 100644 --- a/routes/blockchain.js +++ b/routes/blockchain.js @@ -29,7 +29,7 @@ router.get('/getBestBlockHash', (req, res, next) => { } }) .then((response) => { - res.send(response.data.result); + res.json(response.data.result); }) .catch((error) => { res.send(error.response.data.error.message); @@ -125,7 +125,7 @@ router.get('/getBlockHash/:height', (req, res, next) => { } }) .then((response) => { - res.send(response.data.result); + res.json(response.data.result); }) .catch((error) => { res.send(error.response.data.error.message); @@ -197,7 +197,7 @@ router.get('/getDifficulty', (req, res, next) => { } }) .then((response) => { - res.send(JSON.stringify(response.data.result)); + res.json(JSON.stringify(response.data.result)); }) .catch((error) => { res.send(error.response.data.error.message); @@ -440,7 +440,7 @@ router.post('/pruneBlockchain/:height', (req, res, next) => { } }) .then((response) => { - res.send(response.data.result); + res.json(response.data.result); }) .catch((error) => { res.send(error.response.data.error.message); @@ -485,7 +485,7 @@ router.get('/verifyTxOutProof/:proof', (req, res, next) => { } }) .then((response) => { - res.send(response.data.result); + res.json(response.data.result); }) .catch((error) => { res.send(error.response.data.error.message); diff --git a/routes/generating.js b/routes/generating.js index e85d7e95..35eca260 100644 --- a/routes/generating.js +++ b/routes/generating.js @@ -39,7 +39,7 @@ router.post('/generateToAddress/:nblocks/:address', (req, res, next) => { } }) .then((response) => { - res.send(response.data.result); + res.json(response.data.result); }) .catch((error) => { res.send(error.response.data.error.message); diff --git a/routes/mining.js b/routes/mining.js index e772ba9a..6765883c 100644 --- a/routes/mining.js +++ b/routes/mining.js @@ -32,7 +32,7 @@ router.get('/getBlockTemplate/:templateRequest', (req, res, next) => { } }) .then((response) => { - res.send(response.data.result); + res.json(response.data.result); }) .catch((error) => { res.send(error.response.data.error.message); @@ -104,7 +104,7 @@ router.post('/submitBlock/:hex', (req, res, next) => { } }) .then((response) => { - res.send(response.data.result); + res.json(response.data.result); }) .catch((error) => { res.send(error.response.data.error.message); diff --git a/routes/rawtransactions.js b/routes/rawtransactions.js index f4a4c249..76f648a2 100644 --- a/routes/rawtransactions.js +++ b/routes/rawtransactions.js @@ -110,7 +110,7 @@ router.post('/sendRawTransaction/:hex', (req, res, next) => { } }) .then((response) => { - res.send(response.data.result); + res.json(response.data.result); }) .catch((error) => { res.send(error.response.data.error.message); diff --git a/test/blockchain.js b/test/blockchain.js index c4ea33e1..57f4e1a4 100644 --- a/test/blockchain.js +++ b/test/blockchain.js @@ -32,7 +32,7 @@ describe("#BlockchainRouter", () => { blockchainRoute(mockRequest, mockResponse); mockResponse.on('end', () => { - let actualResponseBody = mockResponse._getData(); + let actualResponseBody = JSON.parse(mockResponse._getData()); assert.equal(actualResponseBody.length, 64); done(); }); @@ -125,7 +125,7 @@ describe("#BlockchainRouter", () => { blockchainRoute(mockRequest, mockResponse); mockResponse.on('end', () => { - let actualResponseBody = mockResponse._getData(); + let actualResponseBody = JSON.parse(mockResponse._getData()); assert.equal(actualResponseBody, "00000000000000000182bf5782f3d43b1a8fceccb50253eb61e58cba7b240edc"); done(); });