From 86335e0c746e0f8d8144c28794e2679098a2a5db Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 2 Apr 2017 14:40:10 -0400 Subject: [PATCH] move http request to utils --- lib/core/engine.js | 3 +-- lib/utils/utils.js | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/core/engine.js b/lib/core/engine.js index 9b1795c3..2edc10a4 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -1,4 +1,3 @@ -let http = require('http'); let Web3 = require('web3'); let utils = require('../utils/utils.js'); let Events = require('./events.js'); @@ -181,7 +180,7 @@ class Engine { //Ideally this method should be in an IPFS API JSONRPC wrapper //The URL should also be flexible to accept non-default IPFS url self.logger.trace("Checking IPFS version..."); - http.get('http://localhost:5001/api/v0/version', function (res) { + utils.httpGet('http://localhost:5001/api/v0/version', function (res) { let body = ''; res.on('data', function (d) { body += d; diff --git a/lib/utils/utils.js b/lib/utils/utils.js index 8828cd31..3460f181 100644 --- a/lib/utils/utils.js +++ b/lib/utils/utils.js @@ -29,6 +29,10 @@ function checkIsAvailable(url, callback) { }); } +function httpGet(url, callback) { + return http.get(url, callback); +} + function runCmd(cmd, options) { let result = shelljs.exec(cmd, options || {silent: true}); if (result.code !== 0) { @@ -60,6 +64,7 @@ module.exports = { fileMatchesPattern: fileMatchesPattern, recursiveMerge: recursiveMerge, checkIsAvailable: checkIsAvailable, + httpGet: httpGet, runCmd: runCmd, cd: cd, sed: sed,