json-proxy-middleware
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -16,2 +16,3 @@ "use strict"; | ||
var request_1 = __importDefault(require("request")); | ||
var verror_1 = __importDefault(require("verror")); | ||
// we use these for more accurate timing when logging | ||
@@ -37,17 +38,12 @@ var NS_PER_SEC = 1e9; | ||
if (typeof host !== "string") { | ||
// error, should likely be converted to a VError | ||
next({ | ||
errors: [ | ||
{ | ||
status: 500, | ||
code: "PROXY_HOST_ERROR", | ||
title: "`urlHost` could not be resolved to a valid string.", | ||
detail: "The options.urlHost provided either was not a string, or the value" + | ||
"returned from invoking urlHost() was not a string.", | ||
meta: { | ||
additionalLogMessage: additionalLogMessage || "" | ||
} | ||
next(new verror_1.default({ | ||
name: "PROXY_HOST_ERROR", | ||
info: { | ||
detail: "The options.urlHost provided either was not a string, or the value" + | ||
"returned from invoking urlHost() was not a string.", | ||
meta: { | ||
additionalLogMessage: additionalLogMessage || "" | ||
} | ||
] | ||
}); | ||
} | ||
}, "`urlHost` could not be resolved to a valid string.")); | ||
return; | ||
@@ -79,33 +75,27 @@ } | ||
requestStream.on("error", function (err) { | ||
return next({ | ||
errors: [ | ||
{ | ||
status: 500, | ||
code: "PROXY_REQUEST_ERROR", | ||
title: "There was an error while making the proxied request.", | ||
detail: "The proxied path is " + urlPath + ". The host is " + host + ".", | ||
meta: { | ||
err: err, | ||
url: "" + host + urlPath | ||
} | ||
return next(new verror_1.default({ | ||
name: "PROXY_REQUEST_ERROR", | ||
cause: err, | ||
info: { | ||
detail: "The proxied path is " + urlPath + ". The host is " + host + ".", | ||
meta: { | ||
additionalLogMessage: additionalLogMessage || "", | ||
url: "" + host + urlPath | ||
} | ||
] | ||
}); | ||
} | ||
}, "There was an error while making the proxied request.")); | ||
}); | ||
var responseStream = requestStream.pipe(res); | ||
responseStream.on("error", function (err) { | ||
return next({ | ||
errors: [ | ||
{ | ||
status: 500, | ||
code: "PROXY_RESPONSE_ERROR", | ||
title: "There was an error while streaming the response.", | ||
detail: "The proxied path is " + urlPath + ". The host is " + host + ".", | ||
meta: { | ||
err: err, | ||
url: "" + host + urlPath | ||
} | ||
return next(new verror_1.default({ | ||
name: "PROXY_RESPONSE_ERROR", | ||
cause: err, | ||
info: { | ||
detail: "The proxied path is " + urlPath + ". The host is " + host + ".", | ||
meta: { | ||
additionalLogMessage: additionalLogMessage || "", | ||
url: "" + host + urlPath | ||
} | ||
] | ||
}); | ||
} | ||
}, "There was an error while streaming the response.")); | ||
}); | ||
@@ -112,0 +102,0 @@ responseStream.on("finish", function () { |
{ | ||
"name": "json-proxy-middleware", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Simple express.js friendly json proxy middleware utility", | ||
"main": "dist/index.js", | ||
"files": [ | ||
"dist/" | ||
], | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
@@ -30,3 +34,4 @@ "build": "gulp", | ||
"lodash": "^4.17.10", | ||
"request": "^2.87.0" | ||
"request": "^2.87.0", | ||
"verror": "1.10.0" | ||
}, | ||
@@ -45,5 +50,4 @@ "devDependencies": { | ||
"tslint-eslint-rules": "5.3.1", | ||
"typescript": "2.9.2", | ||
"verror": "1.10.0" | ||
"typescript": "2.9.2" | ||
} | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12
13225
3
4
129
+ Addedverror@1.10.0