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

View File

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

View File

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

View File

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

View File

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

View File

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