From db2ee2ab2704419d055107e0a934149eec06daef Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Tue, 13 Oct 2015 10:52:02 -0400 Subject: [PATCH 1/2] Added ability to configure HTTP route prefixes. --- lib/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/index.js b/lib/index.js index fa3852a..870ca85 100644 --- a/lib/index.js +++ b/lib/index.js @@ -10,6 +10,7 @@ var MessagesController = require('./messages'); var UtilsController = require('./utils'); var CurrencyController = require('./currency'); var bitcore = require('bitcore'); +var _ = bitcore.deps._; var $ = bitcore.util.preconditions; var Transaction = bitcore.Transaction; var EventEmitter = require('events').EventEmitter; @@ -24,6 +25,8 @@ var InsightAPI = function(options) { inv: [] }; + this.routePrefix = options.routePrefix; + this.txController = new TxController(this.node); }; @@ -31,6 +34,14 @@ InsightAPI.dependencies = ['address', 'web']; inherits(InsightAPI, BaseService); +InsightAPI.prototype.getRoutePrefix = function() { + if (!_.isUndefined(this.routePrefix)) { + return this.routePrefix; + } else { + return this.name; + } +}; + InsightAPI.prototype.start = function(callback) { this.node.services.bitcoind.on('tx', this.transactionHandler.bind(this)); From cc1cbc12adf416d875ee9eb04a16bea56c9f618b Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Tue, 13 Oct 2015 11:15:46 -0400 Subject: [PATCH 2/2] Move undefined check to the constructor. --- lib/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/index.js b/lib/index.js index 870ca85..fa93386 100644 --- a/lib/index.js +++ b/lib/index.js @@ -25,7 +25,11 @@ var InsightAPI = function(options) { inv: [] }; - this.routePrefix = options.routePrefix; + if (!_.isUndefined(options.routePrefix)) { + this.routePrefix = options.routePrefix; + } else { + this.routePrefix = this.name; + } this.txController = new TxController(this.node); }; @@ -35,11 +39,7 @@ InsightAPI.dependencies = ['address', 'web']; inherits(InsightAPI, BaseService); InsightAPI.prototype.getRoutePrefix = function() { - if (!_.isUndefined(this.routePrefix)) { - return this.routePrefix; - } else { - return this.name; - } + return this.routePrefix; }; InsightAPI.prototype.start = function(callback) {