fix(core): update
This commit is contained in:
		
							
								
								
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -15,8 +15,6 @@ node_modules/ | ||||
|  | ||||
| # builds | ||||
| dist/ | ||||
| dist_web/ | ||||
| dist_serve/ | ||||
| dist_ts_web/ | ||||
| dist_*/ | ||||
|  | ||||
| # custom | ||||
| @@ -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
									
								
							
							
						
						
									
										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" | ||||
|   }, | ||||
|   "gitzone": { | ||||
|     "projectType": "npm", | ||||
|     "module": { | ||||
|       "githost": "gitlab.com", | ||||
|       "gitscope": "pushrocks", | ||||
|   | ||||
							
								
								
									
										10727
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										10727
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										35
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								package.json
									
									
									
									
									
								
							| @@ -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" | ||||
|   ] | ||||
| } | ||||
| } | ||||
							
								
								
									
										21
									
								
								readme.md
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								readme.md
									
									
									
									
									
								
							| @@ -8,13 +8,20 @@ dropin replacement for request | ||||
| * [docs (typedoc)](https://pushrocks.gitlab.io/smartrequest/) | ||||
|  | ||||
| ## Status for master | ||||
| [](https://gitlab.com/pushrocks/smartrequest/commits/master) | ||||
| [](https://gitlab.com/pushrocks/smartrequest/commits/master) | ||||
| [](https://www.npmjs.com/package/@pushrocks/smartrequest) | ||||
| [](https://snyk.io/test/npm/@pushrocks/smartrequest) | ||||
| [](https://nodejs.org/dist/latest-v10.x/docs/api/) | ||||
| [](https://nodejs.org/dist/latest-v10.x/docs/api/) | ||||
| [](https://prettier.io/) | ||||
|  | ||||
| Status Category | Status Badge | ||||
| -- | -- | ||||
| GitLab Pipelines | [](https://lossless.cloud) | ||||
| GitLab Pipline Test Coverage | [](https://lossless.cloud) | ||||
| npm | [](https://lossless.cloud) | ||||
| Snyk | [](https://lossless.cloud) | ||||
| TypeScript Support | [](https://lossless.cloud) | ||||
| node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/) | ||||
| Code Style | [](https://lossless.cloud) | ||||
| PackagePhobia (total standalone install weight) | [](https://lossless.cloud) | ||||
| PackagePhobia (package size on registry) | [](https://lossless.cloud) | ||||
| BundlePhobia (total size when bundled) | [](https://lossless.cloud) | ||||
| Platform support | [](https://lossless.cloud) [](https://lossless.cloud) | ||||
|  | ||||
| ## Usage | ||||
|  | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
| @@ -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); | ||||
|   }); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user