fix(core): update
This commit is contained in:
parent
92059a50de
commit
d182832e47
@ -12,6 +12,9 @@ stages:
|
|||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- npm install -g @shipzone/npmci
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
@ -36,6 +39,7 @@ auditProductionDependencies:
|
|||||||
- npmci command npm audit --audit-level=high --only=prod --production
|
- npmci command npm audit --audit-level=high --only=prod --production
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
auditDevDependencies:
|
auditDevDependencies:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${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"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "pushrocks",
|
||||||
"gitrepo": "smartrequest",
|
"gitrepo": "smartrequest",
|
||||||
"shortDescription": "dropin replacement for request",
|
"description": "dropin replacement for request",
|
||||||
"npmPackagename": "@pushrocks/smartrequest",
|
"npmPackagename": "@pushrocks/smartrequest",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
@ -52,4 +52,4 @@
|
|||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -3,7 +3,7 @@ import { tap, expect, expectAsync } from '@pushrocks/tapbundle';
|
|||||||
import * as smartrequest from '../ts/index';
|
import * as smartrequest from '../ts/index';
|
||||||
|
|
||||||
tap.test('should request a html document over https', async () => {
|
tap.test('should request a html document over https', async () => {
|
||||||
await expectAsync(smartrequest.getJson('https://encrypted.google.com/')).toHaveProperty('body')
|
await expectAsync(smartrequest.getJson('https://encrypted.google.com/')).toHaveProperty('body');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should request a JSON document over https', async () => {
|
tap.test('should request a JSON document over https', async () => {
|
||||||
|
@ -70,27 +70,28 @@ export const postFormData = async (
|
|||||||
export const postFormDataUrlEncoded = async (
|
export const postFormDataUrlEncoded = async (
|
||||||
urlArg: string,
|
urlArg: string,
|
||||||
optionsArg: interfaces.ISmartRequestOptions = {},
|
optionsArg: interfaces.ISmartRequestOptions = {},
|
||||||
payloadArg: {key: string, content: string}[]
|
payloadArg: { key: string; content: string }[]
|
||||||
) => {
|
) => {
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
...optionsArg,
|
...optionsArg,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
...optionsArg.headers,
|
...optionsArg.headers,
|
||||||
'content-type': 'application/x-www-form-urlencoded'
|
'content-type': 'application/x-www-form-urlencoded',
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let resultString = '';
|
let resultString = '';
|
||||||
|
|
||||||
for (const keyContentPair of payloadArg) {
|
for (const keyContentPair of payloadArg) {
|
||||||
if (resultString) {
|
if (resultString) {
|
||||||
resultString += '&';
|
resultString += '&';
|
||||||
}
|
}
|
||||||
resultString += `${encodeURIComponent(keyContentPair.key)}=${encodeURIComponent(keyContentPair.content)}`;
|
resultString += `${encodeURIComponent(keyContentPair.key)}=${encodeURIComponent(
|
||||||
|
keyContentPair.content
|
||||||
|
)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// lets fire the actual request for sending the formdata
|
// lets fire the actual request for sending the formdata
|
||||||
const response = await request(urlArg + resultString, requestOptions);
|
const response = await request(urlArg + resultString, requestOptions);
|
||||||
return response;
|
return response;
|
||||||
|
@ -5,5 +5,5 @@ export interface ISmartRequestOptions extends https.RequestOptions {
|
|||||||
keepAlive?: boolean;
|
keepAlive?: boolean;
|
||||||
requestBody?: any;
|
requestBody?: any;
|
||||||
autoJsonParse?: boolean;
|
autoJsonParse?: boolean;
|
||||||
queryParams?: {[key: string]: string}
|
queryParams?: { [key: string]: string };
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ export let request = async (
|
|||||||
|
|
||||||
// parse url
|
// parse url
|
||||||
const parsedUrl = plugins.smarturl.Smarturl.createFromUrl(urlArg, {
|
const parsedUrl = plugins.smarturl.Smarturl.createFromUrl(urlArg, {
|
||||||
searchParams: optionsArg.queryParams || {}
|
searchParams: optionsArg.queryParams || {},
|
||||||
});
|
});
|
||||||
optionsArg.hostname = parsedUrl.hostname;
|
optionsArg.hostname = parsedUrl.hostname;
|
||||||
if (parsedUrl.port) {
|
if (parsedUrl.port) {
|
||||||
|
Loading…
Reference in New Issue
Block a user