fix(core): update

This commit is contained in:
2022-07-29 01:19:50 +02:00
parent d9e6214a7e
commit e8669f0420
13 changed files with 5885 additions and 18009 deletions

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartrequest',
version: '1.1.57',
description: 'dropin replacement for request'
}

View File

@ -1,6 +1,7 @@
export { request, IExtendedIncomingMessage } from './smartrequest.request';
export { ISmartRequestOptions } from './smartrequest.interfaces';
export { request } from './smartrequest.request.js';
export type { IExtendedIncomingMessage } from './smartrequest.request.js';
export type { ISmartRequestOptions } from './smartrequest.interfaces.js';
export * from './smartrequest.jsonrest';
export * from './smartrequest.binaryrest';
export * from './smartrequest.formdata';
export * from './smartrequest.jsonrest.js';
export * from './smartrequest.binaryrest.js';
export * from './smartrequest.formdata.js';

View File

@ -1,8 +1,8 @@
// this file implements methods to get and post binary data.
import * as interfaces from './smartrequest.interfaces';
import { request } from './smartrequest.request';
import * as interfaces from './smartrequest.interfaces.js';
import { request } from './smartrequest.request.js';
import * as plugins from './smartrequest.plugins';
import * as plugins from './smartrequest.plugins.js';
export const getBinary = async (
domainArg: string,

View File

@ -1,6 +1,6 @@
import * as plugins from './smartrequest.plugins';
import * as interfaces from './smartrequest.interfaces';
import { request } from './smartrequest.request';
import * as plugins from './smartrequest.plugins.js';
import * as interfaces from './smartrequest.interfaces.js';
import { request } from './smartrequest.request.js';
/**
* the interfae for FormFieldData
@ -72,7 +72,6 @@ export const postFormDataUrlEncoded = async (
optionsArg: interfaces.ISmartRequestOptions = {},
payloadArg: { key: string; content: string }[]
) => {
let resultString = '';
for (const keyContentPair of payloadArg) {
@ -91,7 +90,7 @@ export const postFormDataUrlEncoded = async (
...optionsArg.headers,
'content-type': 'application/x-www-form-urlencoded',
},
requestBody: resultString
requestBody: resultString,
};
// lets fire the actual request for sending the formdata

View File

@ -1,4 +1,4 @@
import * as plugins from './smartrequest.plugins';
import * as plugins from './smartrequest.plugins.js';
import * as https from 'https';
export interface ISmartRequestOptions extends https.RequestOptions {

View File

@ -1,7 +1,7 @@
// This file implements methods to get and post JSON in a simple manner.
import * as interfaces from './smartrequest.interfaces';
import { request } from './smartrequest.request';
import * as interfaces from './smartrequest.interfaces.js';
import { request } from './smartrequest.request.js';
/**
* gets Json and puts the right headers + handles response aggregation

View File

@ -1,5 +1,5 @@
import * as plugins from './smartrequest.plugins';
import * as interfaces from './smartrequest.interfaces';
import * as plugins from './smartrequest.plugins.js';
import * as interfaces from './smartrequest.interfaces.js';
import { IncomingMessage } from 'http';
@ -57,12 +57,18 @@ 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();
const httpAgent = new plugins.agentkeepalive({
keepAlive: true,
freeSocketTimeout: 4000,
maxFreeSockets: 1,
maxSockets: 100,
maxTotalSockets: 1000,
});
/**
* a custom http agent to make sure we can set custom keepAlive options for speedy subsequent calls
*/
const httpAgentKeepAliveFalse = new plugins.http.Agent({
const httpAgentKeepAliveFalse = new plugins.agentkeepalive({
maxFreeSockets: 0,
keepAlive: false,
keepAliveMsecs: 0,
@ -125,16 +131,16 @@ export let request = async (
// lets determine the request module to use
const requestModule = (() => {
switch (true) {
case parsedUrl.protocol === 'https:' && optionsArg.keepAlive:
case parsedUrl.protocol === 'https' && optionsArg.keepAlive:
optionsArg.agent = httpsAgent;
return plugins.https;
case parsedUrl.protocol === 'https:' && !optionsArg.keepAlive:
case parsedUrl.protocol === 'https' && !optionsArg.keepAlive:
optionsArg.agent = httpsAgentKeepAliveFalse;
return plugins.https;
case parsedUrl.protocol === 'http:' && optionsArg.keepAlive:
case parsedUrl.protocol === 'http' && optionsArg.keepAlive:
optionsArg.agent = httpAgent;
return plugins.http;
case parsedUrl.protocol === 'http:' && !optionsArg.keepAlive:
case parsedUrl.protocol === 'http' && !optionsArg.keepAlive:
optionsArg.agent = httpAgentKeepAliveFalse;
return plugins.http;
}