web-ledger-client
Advanced tools
Comparing version 3.1.0 to 3.2.0
# web-ledger-client ChangeLog | ||
## 3.2.0 - 2019-05-24 | ||
### Added | ||
- A configurable HTTP request timeout. | ||
## 3.1.0 - 2019-05-16 | ||
@@ -4,0 +9,0 @@ |
@@ -43,8 +43,9 @@ ## Classes | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| options | <code>Object</code> | Options for the WebLedgerClient. | | ||
| options.hostname | <code>string</code> | The hostname of the ledger node. | | ||
| [options.logger] | <code>Object</code> | The logger to use. | | ||
| [options.httpsAgent] | [<code>Agent</code>](#Agent) | - A NodeJS HTTPS Agent (`https.Agent`) instance. | | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| options | <code>Object</code> | | Options for the WebLedgerClient. | | ||
| options.hostname | <code>string</code> | | The hostname of the ledger node. | | ||
| [options.logger] | <code>Object</code> | | The logger to use. | | ||
| [options.httpsAgent] | [<code>Agent</code>](#Agent) | | A NodeJS HTTPS Agent (`https.Agent`) instance. | | ||
| [options.timeout] | <code>number</code> | <code>60000</code> | HTTP request timeout in ms. | | ||
@@ -51,0 +52,0 @@ <a name="WebLedgerClient+getRecord"></a> |
@@ -31,6 +31,7 @@ /*! | ||
* @param {Object} [options.logger] - The logger to use. | ||
* @param {Agent} [options.httpsAgent] | ||
* - A NodeJS HTTPS Agent (`https.Agent`) instance. | ||
* @param {Agent} [options.httpsAgent] - A NodeJS HTTPS Agent (`https.Agent`) | ||
* instance. | ||
* @param {number} [options.timeout=60000] - HTTP request timeout in ms. | ||
*/ | ||
constructor({httpsAgent, hostname, logger}) { | ||
constructor({httpsAgent, hostname, logger, timeout = 60000}) { | ||
this.hostname = hostname; | ||
@@ -46,2 +47,3 @@ if(!hostname) { | ||
this.ledgerAgentStatus = null; | ||
this.timeout = timeout; | ||
} | ||
@@ -64,3 +66,4 @@ | ||
const baseURL = ledgerAgent.service.ledgerQueryService; | ||
const queryServiceApi = create({baseURL}); | ||
const queryServiceApi = | ||
create({baseURL, httpsAgent: this.httpsAgent, timeout: this.timeout}); | ||
@@ -71,3 +74,2 @@ this.logger.log(`Retrieving Record [ledger: ${this.hostname}]:`, id); | ||
`?id=${encodeURIComponent(id)}`, {}, { | ||
httpsAgent: this.httpsAgent, | ||
headers: constants.DEFAULT_HEADERS | ||
@@ -130,7 +132,8 @@ }); | ||
const baseURL = await this.getServiceEndpoint({serviceId: service}); | ||
const serviceApi = create({baseURL}); | ||
const serviceApi = | ||
create({baseURL, httpsAgent: this.httpsAgent, timeout: this.timeout}); | ||
const requestHeaders = Object.assign( | ||
{}, constants.DEFAULT_HEADERS, headers); | ||
const response = await serviceApi.get('/', {}, { | ||
httpsAgent: this.httpsAgent, headers: requestHeaders | ||
headers: requestHeaders | ||
}); | ||
@@ -249,5 +252,6 @@ if(response.problem) { | ||
const baseURL = this.ledgerAgent.service[service]; | ||
const serviceApi = create({baseURL}); | ||
const serviceApi = | ||
create({baseURL, httpsAgent: this.httpsAgent, timeout: this.timeout}); | ||
const response = await serviceApi.post('/', document, { | ||
httpsAgent: this.httpsAgent, headers: requestHeaders | ||
headers: requestHeaders | ||
}); | ||
@@ -299,5 +303,6 @@ if(response.problem) { | ||
{}, constants.DEFAULT_HEADERS, headers); | ||
const agentsApi = create({baseURL}); | ||
const agentsApi = | ||
create({baseURL, httpsAgent: this.httpsAgent, timeout: this.timeout}); | ||
const response = await agentsApi.get('/ledger-agents', {}, { | ||
headers: requestHeaders, httpsAgent: this.httpsAgent | ||
headers: requestHeaders | ||
}); | ||
@@ -304,0 +309,0 @@ if(response.problem) { |
{ | ||
"name": "web-ledger-client", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "A WebLedger client.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/digitalbazaar/web-ledger-client", |
45967
835