trooba-http-api
Advanced tools
Comparing version 2.0.1 to 2.0.2
# ChangeLog | ||
## Next | ||
## v2.0.2 | ||
* Added context field to the request object to be added to the pipe context. This will allow plugin easier ways to inject into the context. | ||
* Increased code coverage | ||
@@ -6,0 +7,0 @@ ## No release required |
18
index.js
@@ -22,2 +22,3 @@ 'use strict'; | ||
this.config = config; | ||
this.ctx = {}; | ||
} | ||
@@ -29,2 +30,11 @@ | ||
/* | ||
* Sets a new context | ||
*/ | ||
proto.context = function (ctx) { | ||
const newClient = new Client(this.pipe, this.config); | ||
newClient.ctx = Object.assign({}, ctx); | ||
return newClient; | ||
}; | ||
/** | ||
@@ -37,3 +47,3 @@ * General request | ||
Ctor = Ctor || Request; | ||
return new Ctor(request, this.pipe); | ||
return new Ctor(request, this.pipe, this.ctx); | ||
}; | ||
@@ -100,6 +110,6 @@ | ||
function Request(request, pipe) { | ||
function Request(request, pipe, context) { | ||
this.request = request; | ||
this.pipe = pipe; | ||
this.context = {}; | ||
this.context = context; | ||
} | ||
@@ -150,3 +160,3 @@ | ||
return this.pipe.create(this.context).request(request, callback); | ||
return this.pipe.create(Object.assign({}, this.context)).request(request, callback); | ||
} | ||
@@ -153,0 +163,0 @@ }; |
{ | ||
"name": "trooba-http-api", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "generic API for trooba http and ajax transports", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"test": "./node_modules/mocha/bin/mocha test", | ||
"test-coverage": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec" | ||
"test-coverage": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec" | ||
}, | ||
@@ -27,4 +27,5 @@ "repository": { | ||
"devDependencies": { | ||
"async": "^2.5.0", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^3.1.2", | ||
"istanbul": "^0.4.5", | ||
"trooba": "^2" | ||
@@ -31,0 +32,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11585
4
8
221