fix(core): update

This commit is contained in:
Philipp Kunz 2020-08-24 12:01:38 +00:00
parent c829b06169
commit a0a9e3f824
13 changed files with 10138 additions and 774 deletions

4
.gitignore vendored
View File

@ -15,8 +15,6 @@ node_modules/
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
dist_*/
# custom

View File

@ -19,22 +19,35 @@ mirror:
stage: security
script:
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
snyk:
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command snyk test
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- lossless
- docker
- notpriv
allow_failure: true
# ====================
# test stage
@ -49,9 +62,7 @@ testStable:
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- priv
testBuild:
stage: test
@ -62,9 +73,7 @@ testBuild:
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- notpriv
release:
stage: release
@ -84,6 +93,8 @@ release:
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare

29
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -7,6 +7,7 @@
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",

10727
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,11 +3,11 @@
"version": "1.1.47",
"private": false,
"description": "dropin replacement for request",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild)"
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)"
},
"repository": {
"type": "git",
@ -23,29 +23,32 @@
},
"homepage": "https://gitlab.com/pushrocks/smartrequest#README",
"dependencies": {
"@pushrocks/smartpromise": "^3.0.5",
"@types/form-data": "^2.5.0",
"agentkeepalive": "^4.0.2",
"form-data": "^2.5.1"
"@pushrocks/smartpromise": "^3.0.6",
"agentkeepalive": "^4.1.3",
"form-data": "^3.0.0"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.17",
"@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.24",
"@pushrocks/tapbundle": "^3.0.13",
"@types/node": "^12.7.8",
"tslint": "^5.20.0",
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsrun": "^1.2.12",
"@gitzone/tstest": "^1.0.44",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.6.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_web/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}
}

View File

@ -8,13 +8,20 @@ dropin replacement for request
* [docs (typedoc)](https://pushrocks.gitlab.io/smartrequest/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartrequest/badges/master/build.svg)](https://gitlab.com/pushrocks/smartrequest/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartrequest/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartrequest/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartrequest.svg)](https://www.npmjs.com/package/@pushrocks/smartrequest)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartrequest/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartrequest)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartrequest/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartrequest/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartrequest)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartrequest)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartrequest)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartrequest)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartrequest)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage

View File

@ -34,8 +34,8 @@ tap.skip.test('should deal with unix socks', async () => {
{
headers: {
'Content-Type': 'application/json',
Host: 'docker.sock'
}
Host: 'docker.sock',
},
}
);
console.log(socketResponse.body);

View File

@ -10,17 +10,17 @@ export const getBinary = async (
) => {
optionsArg = {
...optionsArg,
autoJsonParse: false
autoJsonParse: false,
};
const done = plugins.smartpromise.defer();
const response = await request(domainArg, optionsArg, true);
const data = [];
response
.on('data', function(chunk) {
.on('data', function (chunk) {
data.push(chunk);
})
.on('end', function() {
.on('end', function () {
//at this point data is an array of Buffers
//so Buffer.concat() can make us a new Buffer
//of all of them together

View File

@ -31,13 +31,13 @@ const appendFormField = async (formDataArg: plugins.formData, formDataField: IFo
);
formDataArg.append('file', fileData, {
filename: formDataField.fileName ? formDataField.fileName : 'upload.pdf',
contentType: 'application/pdf'
contentType: 'application/pdf',
});
break;
case 'Buffer':
formDataArg.append(formDataField.name, formDataField.payload, {
filename: formDataField.fileName ? formDataField.fileName : 'upload.pdf',
contentType: formDataField.contentType ? formDataField.contentType : 'application/pdf'
contentType: formDataField.contentType ? formDataField.contentType : 'application/pdf',
});
break;
}
@ -57,9 +57,9 @@ export const postFormData = async (
method: 'POST',
headers: {
...optionsArg.headers,
...form.getHeaders()
...form.getHeaders(),
},
requestBody: form
requestBody: form,
};
// lets fire the actual request for sending the formdata

View File

@ -14,7 +14,7 @@ export const getJson = async (
) => {
optionsArg.method = 'GET';
optionsArg.headers = {
...optionsArg.headers
...optionsArg.headers,
};
let response = await request(domainArg, optionsArg);
return response;
@ -37,7 +37,7 @@ export const postJson = async (
// assign the right Content-Type, leaving all other headers in place
optionsArg.headers = {
...optionsArg.headers,
'Content-Type': 'application/json'
'Content-Type': 'application/json',
};
}
let response = await request(domainArg, optionsArg);

View File

@ -14,7 +14,7 @@ const buildUtf8Response = (
const done = plugins.smartpromise.defer<IExtendedIncomingMessage>();
// Continuously update stream with data
let body = '';
incomingMessageArg.on('data', chunkArg => {
incomingMessageArg.on('data', (chunkArg) => {
body += chunkArg;
});
@ -50,7 +50,7 @@ const parseSocketPathAndRoute = (stringToParseArg: string) => {
const result = parseRegex.exec(stringToParseArg);
return {
socketPath: result[1],
path: result[2]
path: result[2],
};
};
@ -65,7 +65,7 @@ const httpAgent = new plugins.agentkeepalive.default();
const httpAgentKeepAliveFalse = new plugins.http.Agent({
maxFreeSockets: 0,
keepAlive: false,
keepAliveMsecs: 0
keepAliveMsecs: 0,
});
/**
@ -79,7 +79,7 @@ const httpsAgent = new plugins.agentkeepalive.HttpsAgent();
const httpsAgentKeepAliveFalse = new plugins.https.Agent({
maxFreeSockets: 0,
keepAlive: false,
keepAliveMsecs: 0
keepAliveMsecs: 0,
});
export let request = async (
@ -94,12 +94,12 @@ export let request = async (
const defaultOptions: interfaces.ISmartRequestOptions = {
// agent: agent,
autoJsonParse: true,
keepAlive: true
keepAlive: true,
};
optionsArg = {
...defaultOptions,
...optionsArg
...optionsArg,
};
// parse url
@ -138,7 +138,7 @@ export let request = async (
})() as typeof plugins.https;
// lets perform the actual request
const requestToFire = requestModule.request(optionsArg, async response => {
const requestToFire = requestModule.request(optionsArg, async (response) => {
if (responseStreamArg) {
done.resolve(response);
} else {
@ -150,7 +150,7 @@ export let request = async (
// lets write the requestBody
if (optionsArg.requestBody) {
if (optionsArg.requestBody instanceof plugins.formData) {
optionsArg.requestBody.pipe(requestToFire).on('finish', event => {
optionsArg.requestBody.pipe(requestToFire).on('finish', (event) => {
requestToFire.end();
});
} else {
@ -167,7 +167,7 @@ export let request = async (
}
// lets handle an error
requestToFire.on('error', e => {
requestToFire.on('error', (e) => {
console.error(e);
});