fix(core): update
This commit is contained in:
parent
c829b06169
commit
a0a9e3f824
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
|||||||
|
|
||||||
# builds
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_web/
|
dist_*/
|
||||||
dist_serve/
|
|
||||||
dist_ts_web/
|
|
||||||
|
|
||||||
# custom
|
# custom
|
@ -19,22 +19,35 @@ mirror:
|
|||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
auditProductionDependencies:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
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
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install --ignore-scripts
|
- 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:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@ -49,9 +62,7 @@ testStable:
|
|||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- priv
|
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
@ -62,9 +73,7 @@ testBuild:
|
|||||||
- npmci command npm run build
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@ -84,6 +93,8 @@ release:
|
|||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g tslint typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal 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
26
.vscode/settings.json
vendored
Normal 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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -7,6 +7,7 @@
|
|||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "pushrocks",
|
||||||
|
11093
package-lock.json
generated
11093
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
33
package.json
33
package.json
@ -3,11 +3,11 @@
|
|||||||
"version": "1.1.47",
|
"version": "1.1.47",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "dropin replacement for request",
|
"description": "dropin replacement for request",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "(tsbuild)"
|
"build": "(tsbuild --web)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -23,29 +23,32 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartrequest#README",
|
"homepage": "https://gitlab.com/pushrocks/smartrequest#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartpromise": "^3.0.5",
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
"@types/form-data": "^2.5.0",
|
"agentkeepalive": "^4.1.3",
|
||||||
"agentkeepalive": "^4.0.2",
|
"form-data": "^3.0.0"
|
||||||
"form-data": "^2.5.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.17",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
"@gitzone/tsrun": "^1.2.8",
|
"@gitzone/tsrun": "^1.2.12",
|
||||||
"@gitzone/tstest": "^1.0.24",
|
"@gitzone/tstest": "^1.0.44",
|
||||||
"@pushrocks/tapbundle": "^3.0.13",
|
"@pushrocks/tapbundle": "^3.2.9",
|
||||||
"@types/node": "^12.7.8",
|
"@types/node": "^14.6.0",
|
||||||
"tslint": "^5.20.0",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
"ts_web/**/*",
|
"ts_web/**/*",
|
||||||
"dist/**/*",
|
"dist/**/*",
|
||||||
"dist_web/**/*",
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
"dist_ts_web/**/*",
|
"dist_ts_web/**/*",
|
||||||
"assets/**/*",
|
"assets/**/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
21
readme.md
21
readme.md
@ -8,13 +8,20 @@ dropin replacement for request
|
|||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartrequest/)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartrequest/)
|
||||||
|
|
||||||
## Status for master
|
## 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)
|
Status Category | Status Badge
|
||||||
[![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)
|
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartrequest/badges/master/pipeline.svg)](https://lossless.cloud)
|
||||||
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartrequest/badges/master/coverage.svg)](https://lossless.cloud)
|
||||||
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartrequest)](https://lossless.cloud)
|
||||||
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
|
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
|
## Usage
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ tap.skip.test('should deal with unix socks', async () => {
|
|||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Host: 'docker.sock'
|
Host: 'docker.sock',
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
console.log(socketResponse.body);
|
console.log(socketResponse.body);
|
||||||
|
@ -10,17 +10,17 @@ export const getBinary = async (
|
|||||||
) => {
|
) => {
|
||||||
optionsArg = {
|
optionsArg = {
|
||||||
...optionsArg,
|
...optionsArg,
|
||||||
autoJsonParse: false
|
autoJsonParse: false,
|
||||||
};
|
};
|
||||||
const done = plugins.smartpromise.defer();
|
const done = plugins.smartpromise.defer();
|
||||||
const response = await request(domainArg, optionsArg, true);
|
const response = await request(domainArg, optionsArg, true);
|
||||||
const data = [];
|
const data = [];
|
||||||
|
|
||||||
response
|
response
|
||||||
.on('data', function(chunk) {
|
.on('data', function (chunk) {
|
||||||
data.push(chunk);
|
data.push(chunk);
|
||||||
})
|
})
|
||||||
.on('end', function() {
|
.on('end', function () {
|
||||||
//at this point data is an array of Buffers
|
//at this point data is an array of Buffers
|
||||||
//so Buffer.concat() can make us a new Buffer
|
//so Buffer.concat() can make us a new Buffer
|
||||||
//of all of them together
|
//of all of them together
|
||||||
|
@ -31,13 +31,13 @@ const appendFormField = async (formDataArg: plugins.formData, formDataField: IFo
|
|||||||
);
|
);
|
||||||
formDataArg.append('file', fileData, {
|
formDataArg.append('file', fileData, {
|
||||||
filename: formDataField.fileName ? formDataField.fileName : 'upload.pdf',
|
filename: formDataField.fileName ? formDataField.fileName : 'upload.pdf',
|
||||||
contentType: 'application/pdf'
|
contentType: 'application/pdf',
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'Buffer':
|
case 'Buffer':
|
||||||
formDataArg.append(formDataField.name, formDataField.payload, {
|
formDataArg.append(formDataField.name, formDataField.payload, {
|
||||||
filename: formDataField.fileName ? formDataField.fileName : 'upload.pdf',
|
filename: formDataField.fileName ? formDataField.fileName : 'upload.pdf',
|
||||||
contentType: formDataField.contentType ? formDataField.contentType : 'application/pdf'
|
contentType: formDataField.contentType ? formDataField.contentType : 'application/pdf',
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -57,9 +57,9 @@ export const postFormData = async (
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
...optionsArg.headers,
|
...optionsArg.headers,
|
||||||
...form.getHeaders()
|
...form.getHeaders(),
|
||||||
},
|
},
|
||||||
requestBody: form
|
requestBody: form,
|
||||||
};
|
};
|
||||||
|
|
||||||
// lets fire the actual request for sending the formdata
|
// lets fire the actual request for sending the formdata
|
||||||
|
@ -14,7 +14,7 @@ export const getJson = async (
|
|||||||
) => {
|
) => {
|
||||||
optionsArg.method = 'GET';
|
optionsArg.method = 'GET';
|
||||||
optionsArg.headers = {
|
optionsArg.headers = {
|
||||||
...optionsArg.headers
|
...optionsArg.headers,
|
||||||
};
|
};
|
||||||
let response = await request(domainArg, optionsArg);
|
let response = await request(domainArg, optionsArg);
|
||||||
return response;
|
return response;
|
||||||
@ -37,7 +37,7 @@ export const postJson = async (
|
|||||||
// assign the right Content-Type, leaving all other headers in place
|
// assign the right Content-Type, leaving all other headers in place
|
||||||
optionsArg.headers = {
|
optionsArg.headers = {
|
||||||
...optionsArg.headers,
|
...optionsArg.headers,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
let response = await request(domainArg, optionsArg);
|
let response = await request(domainArg, optionsArg);
|
||||||
|
@ -14,7 +14,7 @@ const buildUtf8Response = (
|
|||||||
const done = plugins.smartpromise.defer<IExtendedIncomingMessage>();
|
const done = plugins.smartpromise.defer<IExtendedIncomingMessage>();
|
||||||
// Continuously update stream with data
|
// Continuously update stream with data
|
||||||
let body = '';
|
let body = '';
|
||||||
incomingMessageArg.on('data', chunkArg => {
|
incomingMessageArg.on('data', (chunkArg) => {
|
||||||
body += chunkArg;
|
body += chunkArg;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ const parseSocketPathAndRoute = (stringToParseArg: string) => {
|
|||||||
const result = parseRegex.exec(stringToParseArg);
|
const result = parseRegex.exec(stringToParseArg);
|
||||||
return {
|
return {
|
||||||
socketPath: result[1],
|
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({
|
const httpAgentKeepAliveFalse = new plugins.http.Agent({
|
||||||
maxFreeSockets: 0,
|
maxFreeSockets: 0,
|
||||||
keepAlive: false,
|
keepAlive: false,
|
||||||
keepAliveMsecs: 0
|
keepAliveMsecs: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,7 +79,7 @@ const httpsAgent = new plugins.agentkeepalive.HttpsAgent();
|
|||||||
const httpsAgentKeepAliveFalse = new plugins.https.Agent({
|
const httpsAgentKeepAliveFalse = new plugins.https.Agent({
|
||||||
maxFreeSockets: 0,
|
maxFreeSockets: 0,
|
||||||
keepAlive: false,
|
keepAlive: false,
|
||||||
keepAliveMsecs: 0
|
keepAliveMsecs: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
export let request = async (
|
export let request = async (
|
||||||
@ -94,12 +94,12 @@ export let request = async (
|
|||||||
const defaultOptions: interfaces.ISmartRequestOptions = {
|
const defaultOptions: interfaces.ISmartRequestOptions = {
|
||||||
// agent: agent,
|
// agent: agent,
|
||||||
autoJsonParse: true,
|
autoJsonParse: true,
|
||||||
keepAlive: true
|
keepAlive: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
optionsArg = {
|
optionsArg = {
|
||||||
...defaultOptions,
|
...defaultOptions,
|
||||||
...optionsArg
|
...optionsArg,
|
||||||
};
|
};
|
||||||
|
|
||||||
// parse url
|
// parse url
|
||||||
@ -138,7 +138,7 @@ export let request = async (
|
|||||||
})() as typeof plugins.https;
|
})() as typeof plugins.https;
|
||||||
|
|
||||||
// lets perform the actual request
|
// lets perform the actual request
|
||||||
const requestToFire = requestModule.request(optionsArg, async response => {
|
const requestToFire = requestModule.request(optionsArg, async (response) => {
|
||||||
if (responseStreamArg) {
|
if (responseStreamArg) {
|
||||||
done.resolve(response);
|
done.resolve(response);
|
||||||
} else {
|
} else {
|
||||||
@ -150,7 +150,7 @@ export let request = async (
|
|||||||
// lets write the requestBody
|
// lets write the requestBody
|
||||||
if (optionsArg.requestBody) {
|
if (optionsArg.requestBody) {
|
||||||
if (optionsArg.requestBody instanceof plugins.formData) {
|
if (optionsArg.requestBody instanceof plugins.formData) {
|
||||||
optionsArg.requestBody.pipe(requestToFire).on('finish', event => {
|
optionsArg.requestBody.pipe(requestToFire).on('finish', (event) => {
|
||||||
requestToFire.end();
|
requestToFire.end();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -167,7 +167,7 @@ export let request = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// lets handle an error
|
// lets handle an error
|
||||||
requestToFire.on('error', e => {
|
requestToFire.on('error', (e) => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user