faithlife-api
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -7,2 +7,4 @@ /*! | ||
var url = require('url'); | ||
var util = require('util'); | ||
var express = require('express'); | ||
var mi = require('mi'); | ||
@@ -74,11 +76,15 @@ var superagent = require('superagent'); | ||
BaseApiClient.prototype.request = function request(method, path) { | ||
path = this.getUrl(path); | ||
var start = Date.now(); | ||
var href = this.getUrl(path); | ||
console.log('%s %s', method, path); | ||
return superagent(method, path) | ||
return superagent(method, href) | ||
.set('Authorization', this._authorization) | ||
.use(superagentThen) | ||
.on('error', function (err) { | ||
console.error('Error in %s %s: %s', method, path, err); | ||
console.error('Error in %s %s: %s', method, href, err); | ||
}) | ||
.on('response', function (res) { | ||
var ms = Date.now() - start; | ||
console.log('%s %s %s %s ms', method, href, res.statusCode, ms.toFixed(3)); | ||
}); | ||
@@ -125,16 +131,25 @@ }; | ||
var self = this; | ||
var app = require('express')(); | ||
var app = express(); | ||
app.use(function (request, response, next) { | ||
var parsedUrl = url.parse(self.getUrl(request.path)); | ||
var start = Date.now(); | ||
var href = self.getUrl(request.url); | ||
var parsedUrl = url.parse(href); | ||
var outgoing = https.request({ | ||
method: request.method, | ||
hostname: parsedUrl.hostname, | ||
port: parsedUrl.port, | ||
path: parsedUrl.path, | ||
headers: { | ||
'Authorization': request.authorization | ||
} | ||
headers: util._extend(request.headers, { | ||
'Authorization': request.authorization, | ||
'Connection': 'Keep-Alive', | ||
'Host': parsedUrl.host | ||
}) | ||
}); | ||
outgoing.on('response', function (incoming) { | ||
var ms = Date.now() - start; | ||
console.log('%s %s %s %s ms', request.method, href, incoming.statusCode, ms.toFixed(3)); | ||
response.status(incoming.statusCode); | ||
@@ -146,4 +161,2 @@ response.set(incoming.headers); | ||
request.pipe(outgoing); | ||
outgoing.end(); | ||
}); | ||
@@ -150,0 +163,0 @@ |
{ | ||
"name": "faithlife-api", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "A collection of CommonJS modules for interacting with the Faithlife API.", | ||
"main": "lib/index.js", | ||
"browser": { | ||
"express": false | ||
}, | ||
"scripts": { | ||
@@ -17,3 +20,3 @@ "test": "node test" | ||
"mi": "~1.0.0", | ||
"superagent": "git://github.com/Schoonology/superagent", | ||
"superagent": "~0.19.0", | ||
"superagent-then": "~1.0.0", | ||
@@ -20,0 +23,0 @@ "when": "~3.4.4" |
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable and can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
9886
279
0
+ Addedqs@1.2.0(transitive)
+ Addedsuperagent@0.19.1(transitive)
Updatedsuperagent@~0.19.0