diff --git a/lib/index.js b/lib/index.js index 88ffe9a86..de91cfffe 100644 --- a/lib/index.js +++ b/lib/index.js @@ -28,6 +28,7 @@ var EventEmitter = require('events').EventEmitter; * @param {Number} options.cacheLongSeconds - The time to cache long lived cache responses. * @param {String} options.routePrefix - The URL route prefix * @param {String} options.translateAddresses - Translate request and output address to Copay's BCH address version (see https://support.bitpay.com/hc/en-us/articles/115004671663-BitPay-s-Adopted-Conventions-for-Bitcoin-Cash-Addresses-URIs-and-Payment-Requests) + * @param {String} options.maxRequestSize - Max size of request body for body parser to handle e.g '20mb' */ var InsightAPI = function(options) { BaseService.call(this, options); @@ -59,6 +60,8 @@ var InsightAPI = function(options) { this.blockSummaryCacheSize = options.blockSummaryCacheSize || BlockController.DEFAULT_BLOCKSUMMARY_CACHE_SIZE; this.blockCacheSize = options.blockCacheSize || BlockController.DEFAULT_BLOCK_CACHE_SIZE; + this.maxRequestSize = options.maxRequestSize; + if (!_.isUndefined(options.routePrefix)) { this.routePrefix = options.routePrefix; } else { @@ -174,8 +177,14 @@ InsightAPI.prototype.setupRoutes = function(app) { //Enable compression app.use(compression()); - //Enable urlencoded data - app.use(bodyParser.urlencoded({extended: true})); + //Set max request size default:100kb + if(this.maxRequestSize){ + app.use(bodyParser.urlencoded({limit: this.maxRequestSize, extended: true})) + }else { + //Enable urlencoded data + app.use(bodyParser.urlencoded({extended: true})); + } + //Enable CORS app.use(function(req, res, next) {