Compare commits

...

6 Commits

Author SHA1 Message Date
d204059313 1.1.51 2020-09-29 15:22:25 +00:00
00210566d5 fix(core): update 2020-09-29 15:22:25 +00:00
14245b2521 1.1.50 2020-09-29 15:20:41 +00:00
f0fa91e2db fix(core): update 2020-09-29 15:20:40 +00:00
19a1fe1524 1.1.49 2020-08-24 12:04:11 +00:00
27770a8ad1 fix(core): update 2020-08-24 12:04:10 +00:00
4 changed files with 12 additions and 7 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartrequest",
"version": "1.1.48",
"version": "1.1.51",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartrequest",
"version": "1.1.48",
"version": "1.1.51",
"private": false,
"description": "dropin replacement for request",
"main": "dist_ts/index.js",

View File

@ -48,7 +48,7 @@ Use TypeScript for best in class instellisense.
import * as smartrequest from 'smartrequest'
// simple post
let options: smartrequest.ISmartRequestOptions = { // typed options
const options: smartrequest.ISmartRequestOptions = { // typed options
headers: {
"Content-Type": "application/json"
"Authorization": "Bearer token"
@ -66,7 +66,7 @@ smartrequest.request('https://example.com', options).then(res => {
console.log(err)
})
// dedicated JSON metods are available:
// dedicated JSON methods are available:
smartrequest.getJson(...)
smartrequest.postJson(...)
smartrequest.putJson(...)

View File

@ -83,7 +83,7 @@ const httpsAgentKeepAliveFalse = new plugins.https.Agent({
});
export let request = async (
domainArg: string,
urlArg: string,
optionsArg: interfaces.ISmartRequestOptions = {},
responseStreamArg: boolean = false,
requestDataFunc: (req: plugins.http.ClientRequest) => void = null
@ -103,7 +103,7 @@ export let request = async (
};
// parse url
const parsedUrl = plugins.url.parse(domainArg);
const parsedUrl = plugins.url.parse(urlArg);
optionsArg.hostname = parsedUrl.hostname;
if (parsedUrl.port) {
optionsArg.port = parseInt(parsedUrl.port, 10);
@ -111,7 +111,7 @@ export let request = async (
optionsArg.path = parsedUrl.path;
// determine if unixsock
if (testForUnixSock(domainArg)) {
if (testForUnixSock(urlArg)) {
const detailedUnixPath = parseSocketPathAndRoute(optionsArg.path);
optionsArg.socketPath = detailedUnixPath.socketPath;
optionsArg.path = detailedUnixPath.path;
@ -137,6 +137,11 @@ export let request = async (
}
})() as typeof plugins.https;
if (!requestModule) {
console.error(`The request to ${urlArg} is missing a viable protocol. Must be http or https`);
return;
}
// lets perform the actual request
const requestToFire = requestModule.request(optionsArg, async (response) => {
if (responseStreamArg) {