Compare commits

...

7 Commits

Author SHA1 Message Date
2a46f2a306 1.1.45 2020-01-12 19:36:58 +00:00
eae4d09664 fix(core): update 2020-01-12 19:36:58 +00:00
23a2f597fc 1.1.44 2020-01-12 19:32:20 +00:00
c278249c32 fix(core): update 2020-01-12 19:32:20 +00:00
a32c372374 1.1.43 2019-11-21 17:32:31 +00:00
f98972d9fe fix(core): update 2019-11-21 17:32:30 +00:00
acebe6a381 1.1.42 2019-10-28 16:18:15 +01:00
5 changed files with 77 additions and 62 deletions

View File

@ -3,14 +3,14 @@ image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
- .npmci_cache/ - .npmci_cache/
key: "$CI_BUILD_STAGE" key: '$CI_BUILD_STAGE'
stages: stages:
- security - security
- test - test
- release - release
- metadata - metadata
# ==================== # ====================
# security stage # security stage
@ -18,21 +18,23 @@ stages:
mirror: mirror:
stage: security stage: security
script: script:
- npmci git mirror - npmci git mirror
tags: tags:
- docker - lossless
- notpriv - docker
- notpriv
snyk: snyk:
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
stage: security stage: security
script: script:
- npmci npm prepare - npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts - npmci command npm install --ignore-scripts
- npmci command snyk test - npmci command snyk test
tags: tags:
- docker - lossless
- notpriv - docker
- notpriv
# ==================== # ====================
# test stage # test stage
@ -41,37 +43,40 @@ snyk:
testStable: testStable:
stage: test stage: test
script: script:
- npmci npm prepare - npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install
- npmci npm test - npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - lossless
- priv - docker
- priv
testBuild: testBuild:
stage: test stage: test
script: script:
- npmci npm prepare - npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install
- npmci command npm run build - npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - lossless
- notpriv - docker
- notpriv
release: release:
stage: release stage: release
script: script:
- npmci node install stable - npmci node install stable
- npmci npm publish - npmci npm publish
only: only:
- tags - tags
tags: tags:
- docker - lossless
- notpriv - docker
- notpriv
# ==================== # ====================
# metadata stage # metadata stage
@ -85,30 +90,31 @@ codequality:
- npmci npm install - npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts" - npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags: tags:
- docker - lossless
- priv - docker
- priv
trigger: trigger:
stage: metadata stage: metadata
script: script:
- npmci trigger - npmci trigger
only: only:
- tags - tags
tags: tags:
- docker - lossless
- notpriv - docker
- notpriv
pages: pages:
image: hosttoday/ht-docker-dbase:npmci
services:
- docker:stable-dind
stage: metadata stage: metadata
script: script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc - npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command tsdoc - npmci command tsdoc
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
only: only:
@ -116,5 +122,5 @@ pages:
artifacts: artifacts:
expire_in: 1 week expire_in: 1 week
paths: paths:
- public - public
allow_failure: true allow_failure: true

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartrequest", "name": "@pushrocks/smartrequest",
"version": "1.1.41", "version": "1.1.45",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartrequest", "name": "@pushrocks/smartrequest",
"version": "1.1.41", "version": "1.1.45",
"private": false, "private": false,
"description": "dropin replacement for request", "description": "dropin replacement for request",
"main": "dist/index.js", "main": "dist/index.js",
@ -38,12 +38,12 @@
"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_web/**/*",
"dist_ts_web/*", "dist_ts_web/**/*",
"assets/*", "assets/**/*",
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"

View File

@ -22,18 +22,18 @@ Use TypeScript for best in class instellisense.
### Features ### Features
* supports http - supports http
* supports https - supports https
* supports unix socks - supports unix socks
* supports formData - supports formData
* supports file uploads - supports file uploads
* supports best practice keepAlive - supports best practice keepAlive
* dedicated functions for working with JSON request/response cycles - dedicated functions for working with JSON request/response cycles
* written in TypeScript - written in TypeScript
* continuously updated - continuously updated
* uses node native http and https modules - uses node native http and https modules
* used in modules like @pushrocks/smartproxy and @apiglobal/typedrequest - used in modules like @pushrocks/smartproxy and @apiglobal/typedrequest
* commercial support available at [https://lossless.support](https://lossless.support) - commercial support available at [https://lossless.support](https://lossless.support)
> note: smartrequest uses the **native** node http/https modules under the hood (not the bloated one from npm) > note: smartrequest uses the **native** node http/https modules under the hood (not the bloated one from npm)
@ -77,6 +77,10 @@ smartrequest.get('https://example.com/bigfile.mp4', optionsArg, true).then(res =
}) })
``` ```
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
For further information read the linked docs at the top of this readme. For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) > MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)

View File

@ -10,6 +10,7 @@ export interface IFormField {
type: 'string' | 'filePath' | 'Buffer'; type: 'string' | 'filePath' | 'Buffer';
payload: string | Buffer; payload: string | Buffer;
fileName?: string; fileName?: string;
contentType?: string;
} }
const appendFormField = async (formDataArg: plugins.formData, formDataField: IFormField) => { const appendFormField = async (formDataArg: plugins.formData, formDataField: IFormField) => {
@ -19,7 +20,11 @@ const appendFormField = async (formDataArg: plugins.formData, formDataField: IFo
break; break;
case 'filePath': case 'filePath':
if (typeof formDataField.payload !== 'string') { if (typeof formDataField.payload !== 'string') {
throw new Error(`Payload for key ${formDataField.name} must be of type string. Got ${typeof formDataField.payload} instead.`); throw new Error(
`Payload for key ${
formDataField.name
} must be of type string. Got ${typeof formDataField.payload} instead.`
);
} }
const fileData = plugins.fs.readFileSync( const fileData = plugins.fs.readFileSync(
plugins.path.join(process.cwd(), formDataField.payload) plugins.path.join(process.cwd(), formDataField.payload)
@ -30,9 +35,9 @@ const appendFormField = async (formDataArg: plugins.formData, formDataField: IFo
}); });
break; break;
case 'Buffer': case 'Buffer':
formDataArg.append('file', formDataField.payload, { formDataArg.append(formDataField.name, formDataField.payload, {
filename: formDataField.fileName ? formDataField.fileName : 'upload.pdf', filename: formDataField.fileName ? formDataField.fileName : 'upload.pdf',
contentType: 'application/pdf' contentType: formDataField.contentType ? formDataField.contentType : 'application/pdf'
}); });
break; break;
} }