@trayio/threadneedle
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -17,3 +17,6 @@ /* | ||
if (require('./localOnly')(config, key)) { | ||
//For "data" key, if the subbedObject is a string, return that only | ||
var localString = ( key === 'data' && _.isString(subbedObject) ? true : false ); | ||
if (require('./localOnly')(config, key) || localString) { | ||
return subbedObject; | ||
@@ -20,0 +23,0 @@ } else { |
{ | ||
"name": "@trayio/threadneedle", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "A framework for simplifying working with HTTP-based APIs.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -47,3 +47,3 @@ # threadneedle | ||
# API | ||
# API | ||
@@ -54,3 +54,3 @@ * [addMethod](#addmethod) | ||
## addMethod | ||
## addMethod | ||
@@ -160,3 +160,3 @@ The vast majority of threadneedle focuses around this singular method. Whenever you run `addMethod`, you're adding another method to the core `threadneedle` object. | ||
### query | ||
### query | ||
@@ -191,3 +191,3 @@ If you have to specify a lot of parameters in the query string for the URL, you can specify them here. | ||
### expects | ||
### expects | ||
@@ -241,3 +241,3 @@ Usually you'll want to do some kind of validation after you've made a request to a third party service. Typically validations will be one of the following: | ||
### notExpects | ||
### notExpects | ||
@@ -259,3 +259,3 @@ The counterpart to `expects`, except that if __ANY__ of the specified status codes / body strings are found, the method will fail: | ||
### before | ||
### before | ||
@@ -344,3 +344,3 @@ If you'd like to map or alter the `params` before running the main request, you can use | ||
### Function inputs | ||
### Function inputs | ||
@@ -391,3 +391,3 @@ Sometimes you'll have a method which isn't REST-based, or you'd like to use a third-party wrapper. | ||
## global | ||
## global | ||
@@ -448,3 +448,3 @@ Typically you'll be creating one threadneedle instance for each third party API service | ||
### data | ||
### data | ||
@@ -465,3 +465,3 @@ Data for POST, PUT etc that you want to send in every request. Gets deep extended by the `data` | ||
### query | ||
### query | ||
@@ -484,3 +484,3 @@ Query string data that you'd like to send in every request. Gets extended by the `query` object | ||
### options | ||
### options | ||
@@ -502,3 +502,3 @@ The options for the request. Gets deep extended into the `options` object. Great for things | ||
### expects | ||
### expects | ||
@@ -521,3 +521,3 @@ Global [expects](#expects) config. Good for things like always expecting all calls to return with a | ||
### notExpects | ||
### notExpects | ||
@@ -540,3 +540,3 @@ Global [notExpects](#notexpects) config. Good for things like specifically flagging certain status | ||
### before | ||
### before | ||
@@ -558,3 +558,3 @@ A function to run before every query happens. Runs **before** the `before` function declared | ||
### afterSuccess | ||
### afterSuccess | ||
@@ -575,3 +575,3 @@ Runs after a method runs successfully, immediately **before** the `afterSuccess` function | ||
### afterFailure | ||
### afterFailure | ||
@@ -578,0 +578,0 @@ Runs after a method runs successfully, immediately **before** the `afterFailure` function |
@@ -91,3 +91,4 @@ var assert = require('assert'); | ||
app = express(); | ||
app.use(bodyParser()); | ||
app.use(bodyParser.json()); | ||
app.use(bodyParser.urlencoded()); | ||
server = app.listen(4000, done); | ||
@@ -94,0 +95,0 @@ }); |
@@ -199,2 +199,23 @@ var assert = require('assert'); | ||
it('should return local string if data is a string', function () { | ||
var sample = { | ||
_globalOptions: { | ||
data: { | ||
id: '123', | ||
name: 'Chris' | ||
} | ||
} | ||
}; | ||
assert.deepEqual( | ||
globalize.object.call(sample, 'data', { | ||
globals: false, | ||
data: "Lorem ipsum" | ||
}, {}), | ||
"Lorem ipsum" | ||
); | ||
}); | ||
it('should not globalize when globals is false', function () { | ||
@@ -201,0 +222,0 @@ var sample = { |
102720
2550