notification-processor
Advanced tools
Comparing version 1.10.4 to 1.11.0
(function() { | ||
var MESSAGE_PROPERTIES, RequestError, StatusCodeError, _, _retrieveMessage, _safeParse, ref, request; | ||
var MESSAGE_PROPERTIES, Promise, RequestError, StatusCodeError, _, _retrieveMessage, _safeParse, ref, request; | ||
_ = require("lodash"); | ||
Promise = require("bluebird"); | ||
request = require("request-promise"); | ||
@@ -30,34 +32,35 @@ | ||
return function(notification) { | ||
var __isSilentError, options; | ||
var __isSilentError; | ||
__isSilentError = function(err) { | ||
return err.constructor === StatusCodeError && _.includes(silentErrors, err.statusCode); | ||
}; | ||
options = requestGenerator(notification); | ||
return request(options).promise()["catch"](__isSilentError, function(err) { | ||
return _.omit(err, "response"); | ||
})["catch"](StatusCodeError, function(arg1) { | ||
var error, statusCode; | ||
statusCode = arg1.statusCode, error = arg1.error; | ||
throw { | ||
message: _(_safeParse(error)).pick(MESSAGE_PROPERTIES).values().map(_retrieveMessage).compact().head(), | ||
detail: { | ||
response: { | ||
statusCode: statusCode, | ||
body: error | ||
return Promise.method(requestGenerator)(notification).then(function(options) { | ||
return request(options).promise()["catch"](__isSilentError, function(err) { | ||
return _.omit(err, "response"); | ||
})["catch"](StatusCodeError, function(arg1) { | ||
var error, statusCode; | ||
statusCode = arg1.statusCode, error = arg1.error; | ||
throw { | ||
message: _(_safeParse(error)).pick(MESSAGE_PROPERTIES).values().map(_retrieveMessage).compact().head(), | ||
detail: { | ||
response: { | ||
statusCode: statusCode, | ||
body: error | ||
} | ||
} | ||
} | ||
}; | ||
})["catch"](RequestError, function(arg1) { | ||
var cause; | ||
cause = arg1.cause; | ||
throw { | ||
message: cause.code, | ||
detail: cause | ||
}; | ||
}).tapCatch(function(err) { | ||
return _.defaultsDeep(err, { | ||
message: "unknown", | ||
detail: { | ||
request: options | ||
} | ||
}; | ||
})["catch"](RequestError, function(arg1) { | ||
var cause; | ||
cause = arg1.cause; | ||
throw { | ||
message: cause.code, | ||
detail: cause | ||
}; | ||
}).tapCatch(function(err) { | ||
return _.defaultsDeep(err, { | ||
message: "unknown", | ||
detail: { | ||
request: options | ||
} | ||
}); | ||
}); | ||
@@ -64,0 +67,0 @@ }); |
(function() { | ||
var DOMAIN, MESSAGE, PATH, RequestProcessor, errors, nock, nockStub, req, should, sinon; | ||
var DOMAIN, MESSAGE, PATH, Promise, RequestProcessor, errors, nock, nockStub, req, should, sinon; | ||
@@ -14,2 +14,4 @@ nock = require("nock"); | ||
Promise = require("bluebird"); | ||
RequestProcessor = require("./request.processor"); | ||
@@ -55,3 +57,3 @@ | ||
}); | ||
return it("should do a POST request and its should be ignored if is a silent errors", function() { | ||
it("should do a POST request and its should be ignored if is a silent errors", function() { | ||
var nockDomain, spy; | ||
@@ -68,2 +70,16 @@ nockDomain = nockStub().reply(409, {}); | ||
}); | ||
return it("should do a POST request event if is called with a promise and it should be successful", function() { | ||
var nockDomain, spy; | ||
nockDomain = nockStub().reply(200, {}); | ||
spy = sinon.spy((function(_this) { | ||
return function() { | ||
return Promise.resolve(req()); | ||
}; | ||
})(this)); | ||
return RequestProcessor(spy)(MESSAGE).should.be.fulfilled().tap(function() { | ||
return nockDomain.done(); | ||
}).tap(function() { | ||
return spy.should.be.calledWith(MESSAGE); | ||
}); | ||
}); | ||
}); | ||
@@ -70,0 +86,0 @@ |
{ | ||
"name": "notification-processor", | ||
"version": "1.10.4", | ||
"version": "1.11.0", | ||
"description": "notification-processor", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -0,0 +0,0 @@ # notification-processor |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
70480
38
1338
1