sendgrid-rest
Advanced tools
+6
-0
@@ -6,2 +6,8 @@ # Change Log | ||
| ## [2.3.0] - 2016-10-12 | ||
| ### Added | ||
| - Pull #6, Solves #5 | ||
| - Invoke the API callback with a mocked response upon Error | ||
| - Thanks [Dan Foley](https://github.com/cantremember)! | ||
| ## [2.2.2] - 2016-09-27 | ||
@@ -8,0 +14,0 @@ ### Fixed |
+8
-1
@@ -113,3 +113,10 @@ 'use strict' | ||
| httpRequest.on('error', function (e) { | ||
| console.log('Error: ' + e.message) | ||
| var response = JSON.parse(JSON.stringify(emptyResponse)) | ||
| response.statusCode = e.statusCode || 500 | ||
| response.body = JSON.stringify({ | ||
| message: e.message, | ||
| name: e.name, | ||
| stack: e.stack, | ||
| }) | ||
| callback(response) | ||
| }) | ||
@@ -116,0 +123,0 @@ |
+1
-1
@@ -8,3 +8,3 @@ { | ||
| "description": "HTTP REST client, simplified for Node.js.", | ||
| "version": "2.2.2", | ||
| "version": "2.3.0", | ||
| "homepage": "https://sendgrid.com", | ||
@@ -11,0 +11,0 @@ "repository": { |
+39
-0
@@ -172,3 +172,42 @@ var assert = require('chai').assert | ||
| }) | ||
| it('should consider non-HTTP-200 repsonses to be valid', function (done) { | ||
| nock(TEST_HOST) | ||
| .get('/test') | ||
| .delay(100) // it('should wait for the response before invoking the callback') | ||
| .reply(503) | ||
| var requestGet = client.emptyRequest() | ||
| requestGet.method = 'GET' | ||
| requestGet.path = '/test' | ||
| client.API(requestGet, function (response) { | ||
| assert.equal(response.statusCode, '503', 'response.StatusCode equal 503') | ||
| assert.equal(response.body, '', | ||
| 'response.body blank') | ||
| assert.equal(JSON.stringify(response.headers), | ||
| '{}', | ||
| 'response.headers blank') | ||
| done() | ||
| }) | ||
| }) | ||
| it('should respond with a mock HTTP 500 response upon Error', function (done) { | ||
| nock(TEST_HOST) | ||
| .get('/test') | ||
| .replyWithError('ERROR') | ||
| var requestGet = client.emptyRequest() | ||
| requestGet.method = 'GET' | ||
| requestGet.path = '/test' | ||
| client.API(requestGet, function (response) { | ||
| assert.equal(response.statusCode, '500', 'response.StatusCode equal 500') | ||
| var body = JSON.parse(response.body) | ||
| assert.equal(body.message, 'ERROR', 'response.body.message equal ERROR') | ||
| assert.equal(body.name, Error.name, 'response.body.name equal Error.name') | ||
| assert.equal(typeof body.stack, 'string', 'response.body.stack is a String') | ||
| assert.equal(JSON.stringify(response.headers), | ||
| '{}', | ||
| 'response.headers blank') | ||
| done() | ||
| }) | ||
| }) | ||
| }) | ||
| }) |
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
31612
6.42%413
11.92%