Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ README.html
public

package-lock.json
mynode/
65 changes: 65 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"excludeFiles": ["node_modules/**", "mynode/**"],

"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"try",
"catch"
],
"requireOperatorBeforeLineBreak": true,
"requireCamelCaseOrUpperCaseIdentifiers": true,
"maximumLineLength": {
"value": 200,
"allowComments": true,
"allowRegex": true
},
"validateIndentation": 2,
"validateQuoteMarks": "'",

"disallowMultipleLineStrings": true,
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowMultipleVarDecl": null,

"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"return",
"try",
"catch"
],
"requireSpaceBeforeBinaryOperators": [
"=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
"&=", "|=", "^=", "+=",

"+", "-", "*", "/", "%", "<<", ">>", ">>>", "&",
"|", "^", "&&", "||", "===", "==", ">=",
"<=", "<", ">", "!=", "!=="
],
"requireSpaceAfterBinaryOperators": true,
"requireSpacesInConditionalExpression": true,
"requireSpaceBeforeBlockStatements": true,
"disallowSpacesInsideObjectBrackets": "all",
"disallowSpacesInsideArrayBrackets": "all",
"disallowSpacesInsideParentheses": true,

"disallowMultipleLineBreaks": true,

"disallowCommaBeforeLineBreak": null,
"disallowDanglingUnderscores": null,
"disallowEmptyBlocks": null,
"disallowTrailingComma": null,
"requireCommaBeforeLineBreak": null,
"requireDotNotation": null,
"requireMultipleVarDecl": null,
"requireParenthesesAroundIIFE": true
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ npm install -g bitcore@latest
bitcore create mynode
cd mynode
bitcore install insight-api
bitcore install insight-ui
bitcore start
```

Expand Down
23 changes: 17 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,22 @@ var InsightAPI = function(options) {
// in minutes
this.currencyRefresh = options.currencyRefresh || CurrencyController.DEFAULT_CURRENCY_DELAY;
this.currency = options.currency || 'BTC';
this._explorers = options.explorers || [{
name: 'Bitcoin',
ticker: 'BTC',
url: 'https://insight.bitpay.com'
}];

this._explorers = [];
if (options.showExplorers) {
this._explorers = options.explorers || [
{
name: 'Bitcoin',
ticker: 'BTC',
url: 'https://insight.bitpay.com'
},
{
name: 'Bitcoin Cash',
ticker: 'BCH',
url: 'https://bch-insight.bitpay.com'
}
];
}

this.subscriptions = {
inv: []
Expand Down Expand Up @@ -164,7 +175,7 @@ InsightAPI.prototype.setupRoutes = function(app) {
}

//Setup logging
morgan.token('remote-forward-addr', function(req){
morgan.token('remote-forward-addr', function(req) {
return self.getRemoteAddress(req);
});
var logFormat = ':remote-forward-addr ":method :url" :status :res[content-length] :response-time ":user-agent" ';
Expand Down
7 changes: 5 additions & 2 deletions test/currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,17 @@ describe('Currency', function() {
var res = {
jsonp: function(response) {
response.status.should.equal(200);
should.exist(response.data.bitstamp);
response.data.bitstamp.should.equal(237.90);
node.log.error.callCount.should.equal(1);
done();
}
};
currency.index(req, res);
});

/*
* TODO properly implement this test
*/
/*
it('will retrieve a cached value', function(done) {
var request = sinon.stub();
var TestCurrencyController = proxyquire('../lib/currency', {
Expand All @@ -106,5 +108,6 @@ describe('Currency', function() {
};
currency.index(req, res);
});
*/

});