fix(core): update
This commit is contained in:
parent
d9e6214a7e
commit
e8669f0420
@ -18,17 +18,6 @@ before_script:
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
@ -100,10 +89,9 @@ codequality:
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci command npm install -g typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
@ -123,11 +111,10 @@ trigger:
|
||||
pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci node install stable
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
- npmci command npm run buildDocs
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
|
23762
package-lock.json
generated
23762
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -5,9 +5,11 @@
|
||||
"description": "dropin replacement for request",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web)"
|
||||
"build": "(tsbuild --web)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -23,17 +25,17 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/smartrequest#README",
|
||||
"dependencies": {
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"@pushrocks/smarturl": "^2.0.1",
|
||||
"agentkeepalive": "^4.2.0",
|
||||
"@pushrocks/smartpromise": "^3.1.7",
|
||||
"@pushrocks/smarturl": "^3.0.2",
|
||||
"agentkeepalive": "^4.2.1",
|
||||
"form-data": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.29",
|
||||
"@gitzone/tsrun": "^1.2.18",
|
||||
"@gitzone/tstest": "^1.0.64",
|
||||
"@pushrocks/tapbundle": "^4.0.7",
|
||||
"@types/node": "^17.0.18",
|
||||
"@gitzone/tsbuild": "^2.1.63",
|
||||
"@gitzone/tsrun": "^1.2.37",
|
||||
"@gitzone/tstest": "^1.0.72",
|
||||
"@pushrocks/tapbundle": "^5.0.4",
|
||||
"@types/node": "^18.6.2",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
@ -52,4 +54,4 @@
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import { tap, expect, expectAsync } from '@pushrocks/tapbundle';
|
||||
|
||||
import * as smartrequest from '../ts/index';
|
||||
import * as smartrequest from '../ts/index.js';
|
||||
|
||||
tap.test('should request a html document over https', async () => {
|
||||
await expectAsync(smartrequest.getJson('https://encrypted.google.com/')).toHaveProperty('body');
|
||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal 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'
|
||||
}
|
11
ts/index.ts
11
ts/index.ts
@ -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';
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
10
tsconfig.json
Normal file
10
tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
||||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"member-ordering": {
|
||||
"options":{
|
||||
"order": [
|
||||
"static-method"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
Loading…
Reference in New Issue
Block a user