fix(core): update

This commit is contained in:
2021-05-16 23:39:25 +00:00
parent d204059313
commit f4f50c6a94
5 changed files with 2780 additions and 1576 deletions

View File

@ -5,4 +5,5 @@ export interface ISmartRequestOptions extends https.RequestOptions {
keepAlive?: boolean;
requestBody?: any;
autoJsonParse?: boolean;
queryParams?: {[key: string]: string}
}

View File

@ -1,15 +1,19 @@
import formData from 'form-data';
// node native scope
import * as fs from 'fs';
import * as http from 'http';
import * as https from 'https';
import * as path from 'path';
import * as url from 'url';
export { http, https, fs, path };
// pushrocks scope
import * as smartpromise from '@pushrocks/smartpromise';
import * as smarturl from '@pushrocks/smarturl';
export { formData, http, https, fs, path, url, smartpromise };
export { smartpromise, smarturl };
// third party scope
import * as agentkeepalive from 'agentkeepalive';
import agentkeepalive from 'agentkeepalive';
import formData from 'form-data';
export { agentkeepalive };
export { agentkeepalive, formData };

View File

@ -57,7 +57,7 @@ const parseSocketPathAndRoute = (stringToParseArg: string) => {
/**
* a custom http agent to make sure we can set custom keepAlive options for speedy subsequent calls
*/
const httpAgent = new plugins.agentkeepalive.default();
const httpAgent = new plugins.agentkeepalive();
/**
* a custom http agent to make sure we can set custom keepAlive options for speedy subsequent calls
@ -103,12 +103,15 @@ export let request = async (
};
// parse url
const parsedUrl = plugins.url.parse(urlArg);
const parsedUrl = plugins.smarturl.Smarturl.createFromUrl(urlArg, {
searchParams: optionsArg.queryParams || {}
});
optionsArg.hostname = parsedUrl.hostname;
if (parsedUrl.port) {
optionsArg.port = parseInt(parsedUrl.port, 10);
}
optionsArg.path = parsedUrl.path;
optionsArg.queryParams = parsedUrl.searchParams;
// determine if unixsock
if (testForUnixSock(urlArg)) {