fix(core): update

This commit is contained in:
Philipp Kunz 2020-06-25 23:53:05 +00:00
parent 5d673799cc
commit 5acbf420ae
7 changed files with 407 additions and 342 deletions

707
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,15 +9,16 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild --web)", "build": "(tsbuild --web && tsbundle npm)",
"format": "(gitzone format)" "format": "(gitzone format)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.24", "@gitzone/tsbuild": "^2.1.24",
"@gitzone/tsbundle": "^1.0.69",
"@gitzone/tstest": "^1.0.33", "@gitzone/tstest": "^1.0.33",
"@pushrocks/smartexpress": "^3.0.69", "@pushrocks/smartexpress": "^3.0.72",
"@pushrocks/tapbundle": "^3.2.1", "@pushrocks/tapbundle": "^3.2.1",
"@types/node": "^14.0.13", "@types/node": "^14.0.14",
"tslint": "^6.1.2", "tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
@ -25,8 +26,7 @@
"@apiglobal/typedrequest-interfaces": "^1.0.13", "@apiglobal/typedrequest-interfaces": "^1.0.13",
"@pushrocks/lik": "^4.0.13", "@pushrocks/lik": "^4.0.13",
"@pushrocks/smartdelay": "^2.0.9", "@pushrocks/smartdelay": "^2.0.9",
"@pushrocks/smartjson": "^3.0.10", "@pushrocks/webrequest": "^2.0.9"
"@pushrocks/smartrequest": "^1.1.47"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",
@ -40,4 +40,4 @@
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
] ]
} }

View File

@ -54,6 +54,7 @@ tap.test('should fire a request', async () => {
const response = await typedRequest.fire({ const response = await typedRequest.fire({
name: 'really' name: 'really'
}); });
console.log('this is the response:');
console.log(response); console.log(response);
expect(response.surname).to.equal('wow'); expect(response.surname).to.equal('wow');
}); });

View File

@ -42,12 +42,11 @@ export class TypedHandler<T extends plugins.typedRequestInterfaces.ITypedRequest
data: typedResponseError.errorData data: typedResponseError.errorData
}; };
} }
if (response) { if (response) {
typedRequestArg.response = response; typedRequestArg.response = response;
} }
return typedRequestArg; return typedRequestArg;
} }
} }

View File

@ -2,6 +2,7 @@ import * as plugins from './typedrequest.plugins';
import { TypedResponseError } from './typedrequest.classes.typedresponseerror'; import { TypedResponseError } from './typedrequest.classes.typedresponseerror';
export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest> { export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest> {
public webrequest = new plugins.webrequest.WebRequest();
public urlEndPoint: string; public urlEndPoint: string;
public method: string; public method: string;
@ -15,16 +16,18 @@ export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest
* firest the request * firest the request
*/ */
public async fire(fireArg: T['request']): Promise<T['response']> { public async fire(fireArg: T['request']): Promise<T['response']> {
const response = await plugins.smartrequest.postJson(this.urlEndPoint, { const response = await this.webrequest.postJson(this.urlEndPoint, {
requestBody: { method: this.method,
method: this.method, request: fireArg,
request: fireArg, response: null
response: null
}
}); });
const responseBody: T = response.body; const responseBody: T = response;
if (responseBody.error) { if (responseBody.error) {
console.error(`Got an error ${responseBody.error.text} with data ${JSON.stringify(responseBody.error.data)}`); console.error(
`Got an error ${responseBody.error.text} with data ${JSON.stringify(
responseBody.error.data
)}`
);
if (!responseBody.retry) { if (!responseBody.retry) {
throw new TypedResponseError(responseBody.error.text, responseBody.error.data); throw new TypedResponseError(responseBody.error.text, responseBody.error.data);
} }

View File

@ -7,4 +7,4 @@ export class TypedResponseError {
this.errorText = errorTextArg; this.errorText = errorTextArg;
this.errorData = errorDataArg; this.errorData = errorDataArg;
} }
} }

View File

@ -6,7 +6,6 @@ export { typedRequestInterfaces };
// pushrocks scope // pushrocks scope
import * as lik from '@pushrocks/lik'; import * as lik from '@pushrocks/lik';
import * as smartdelay from '@pushrocks/smartdelay'; import * as smartdelay from '@pushrocks/smartdelay';
import * as smartrequest from '@pushrocks/smartrequest'; import * as webrequest from '@pushrocks/webrequest';
import * as smartjson from '@pushrocks/smartjson';
export { lik, smartdelay, smartrequest, smartjson }; export { lik, smartdelay, webrequest };