Compare commits

..

10 Commits

Author SHA1 Message Date
752bbd74b0 2.0.6 2019-09-27 21:20:06 +02:00
467f8d3254 fix(core): update 2019-09-27 21:20:06 +02:00
9ff7713103 2.0.5 2019-09-27 20:44:43 +02:00
30de4add37 2.0.4 2019-09-27 20:16:29 +02:00
434dbd718a fix(core): update 2019-09-27 20:16:28 +02:00
94cb734f9f 2.0.3 2019-09-27 14:05:43 +02:00
e03edc6bbf 2.0.2 2019-09-27 14:04:52 +02:00
03c4340e4c fix(core): update 2019-09-27 14:04:52 +02:00
f048bd407b 2.0.1 2019-09-26 22:33:16 +02:00
93a43d7ff5 fix(core): update 2019-09-26 22:33:15 +02:00
8 changed files with 1441 additions and 876 deletions

View File

@ -1,5 +1,5 @@
# gitzone ci_default # gitzone ci_default
image: hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
@ -38,19 +38,7 @@ snyk:
# test stage # test stage
# ==================== # ====================
testLTS: testStable:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
stage: test stage: test
script: script:
- npmci npm prepare - npmci npm prepare
@ -60,6 +48,18 @@ testSTABLE:
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- priv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv - notpriv
release: release:
@ -82,7 +82,7 @@ codequality:
script: script:
- npmci command npm install -g tslint typescript - npmci command npm install -g tslint typescript
- 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 - docker
- priv - priv
@ -98,7 +98,9 @@ trigger:
- notpriv - notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmci image: hosttoday/ht-docker-dbase:npmci
services:
- docker:stable-dind
stage: metadata stage: metadata
script: script:
- npmci command npm install -g @gitzone/tsdoc - npmci command npm install -g @gitzone/tsdoc

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"
}
]
}

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

@ -0,0 +1,20 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone"
}
}
}
}
]
}

2183
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/webrequest", "name": "@pushrocks/webrequest",
"version": "2.0.0", "version": "2.0.6",
"private": false, "private": false,
"description": "securely request from browsers", "description": "securely request from browsers",
"main": "dist/index.js", "main": "dist/index.js",
@ -13,23 +13,24 @@
"format": "(gitzone format)" "format": "(gitzone format)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.3", "@gitzone/tsbuild": "^2.1.17",
"@gitzone/tstest": "^1.0.17", "@gitzone/tstest": "^1.0.24",
"@pushrocks/smartexpress": "^2.0.4", "@pushrocks/smartexpress": "^3.0.40",
"@pushrocks/tapbundle": "^3.0.7", "@pushrocks/tapbundle": "^3.0.13",
"@types/node": "^10.12.12", "@types/node": "^12.7.8",
"node-fetch": "^2.3.0", "node-fetch": "^2.6.0",
"tslint": "^5.17.0", "tslint": "^5.20.0",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartdelay": "^2.0.2" "@pushrocks/smartdelay": "^2.0.3"
}, },
"files": [ "files": [
"ts/*", "ts/*",
"ts_web/*", "ts_web/*",
"dist/*", "dist/*",
"dist_web/*", "dist_web/*",
"dist_ts_web/*",
"assets/*", "assets/*",
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",

View File

@ -21,6 +21,6 @@ securely request from browsers
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)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html) | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com) [![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -60,11 +60,17 @@ tap.test('first test', async tools => {
'http://localhost:2345/apiroute3' 'http://localhost:2345/apiroute3'
]); ]);
const response2 = await new webrequest.WebRequest().getJson('http://localhost:2345/apiroute3');
console.log(response); console.log(response);
console.log(response2)
expect(response) expect(response)
.property('hithere') .property('hithere')
.to.equal('hi'); .to.equal('hi');
expect(response2)
.property('hithere')
.to.equal('hi');
}); });
tap.test('tear down server', async () => { tap.test('tear down server', async () => {

View File

@ -4,9 +4,8 @@ import * as plugins from './webrequest.plugins';
* web request * web request
*/ */
export class WebRequest { export class WebRequest {
public async getJson(urlArg: string | string[], requestBody?: any) { public async getJson(urlArg: string | string[]) {
const response: Response = await this.request(urlArg, { const response: Response = await this.request(urlArg, {
body: requestBody,
method: 'GET' method: 'GET'
}); });
return response.json(); return response.json();
@ -17,8 +16,8 @@ export class WebRequest {
*/ */
public async postJson(urlArg: string, requestBody?: any) { public async postJson(urlArg: string, requestBody?: any) {
const response: Response = await this.request(urlArg, { const response: Response = await this.request(urlArg, {
body: requestBody, body: JSON.stringify(requestBody),
method: 'GET' method: 'POST'
}); });
return response.json(); return response.json();
} }
@ -28,8 +27,8 @@ export class WebRequest {
*/ */
public async putJson(urlArg: string, requestBody?: any) { public async putJson(urlArg: string, requestBody?: any) {
const response: Response = await this.request(urlArg, { const response: Response = await this.request(urlArg, {
body: requestBody, body: JSON.stringify(requestBody),
method: 'GET' method: 'PUT'
}); });
return response.json(); return response.json();
} }
@ -37,18 +36,17 @@ export class WebRequest {
/** /**
* put js * put js
*/ */
public async deleteJson(urlArg: string, requestBody?: any) { public async deleteJson(urlArg: string) {
const response: Response = await this.request(urlArg, { const response: Response = await this.request(urlArg, {
body: requestBody,
method: 'GET' method: 'GET'
}); });
return response.json(); return response.json();
} }
/** /**
* * a fault tolerant request
*/ */
async request( public async request(
urlArg: string | string[], urlArg: string | string[],
optionsArg: { optionsArg: {
method: 'GET' | 'POST' | 'PUT' | 'DELETE'; method: 'GET' | 'POST' | 'PUT' | 'DELETE';
@ -91,7 +89,7 @@ export class WebRequest {
if (!urlToUse) { if (!urlToUse) {
throw new Error('request failed permanently'); throw new Error('request failed permanently');
} }
console.log(`Getting ${urlToUse} with method ${optionsArg.method}`);
const response = await fetch(urlToUse, { const response = await fetch(urlToUse, {
method: optionsArg.method, method: optionsArg.method,
headers: { headers: {
@ -110,7 +108,7 @@ export class WebRequest {
} }
}; };
const finalResponse: Response = await doRequest(urlArg[usedUrlIndex]); const finalResponse: Response = await doRequest(allUrls[usedUrlIndex]);
console.log(finalResponse); console.log(finalResponse);
return finalResponse; return finalResponse;
} }