Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
9db92be274 | |||
4a06bedf3b | |||
9787adf3f0 | |||
280e67b86b | |||
592e941211 |
8
package-lock.json
generated
8
package-lock.json
generated
@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@apiglobal/typedrequest",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.14",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@apiglobal/typedrequest-interfaces": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@apiglobal/typedrequest-interfaces/-/typedrequest-interfaces-1.0.6.tgz",
|
||||
"integrity": "sha512-CNy34tOenPL00hElj6BtPSZ2V3wano3XXPMxATOqrQYGY5x7ik6jLZCMjMhi7dlgFeAe4CUI28QEutaOEnqLBQ=="
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@apiglobal/typedrequest-interfaces/-/typedrequest-interfaces-1.0.7.tgz",
|
||||
"integrity": "sha512-yPl0UcLFMwSQL7bK52wVjkgvadC+x2YS3+7T15V1A1dXNxa96yd4WX1fqcKqwnBrvYexq/8FaxWGi98tZ0oNwg=="
|
||||
},
|
||||
"@babel/code-frame": {
|
||||
"version": "7.5.5",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@apiglobal/typedrequest",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.14",
|
||||
"private": false,
|
||||
"description": "make typed requests towards apis",
|
||||
"main": "dist/index.js",
|
||||
@ -21,7 +21,7 @@
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apiglobal/typedrequest-interfaces": "^1.0.6",
|
||||
"@apiglobal/typedrequest-interfaces": "^1.0.7",
|
||||
"@pushrocks/smartrequest": "^1.1.23"
|
||||
},
|
||||
"files": [
|
||||
|
29
ts/index.ts
29
ts/index.ts
@ -1,27 +1,2 @@
|
||||
import * as plugins from './typedrequest.plugins';
|
||||
|
||||
export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest> {
|
||||
public urlEndPoint: string;
|
||||
public method: string;
|
||||
|
||||
// STATIC
|
||||
constructor(urlEndPointArg: string, methodArg: T['method']) {
|
||||
this.urlEndPoint = urlEndPointArg;
|
||||
this.method = methodArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* firest the request
|
||||
*/
|
||||
public async fire(fireArg: T['request']): Promise<T['response']> {
|
||||
const response = await plugins.smartrequest.request(this.urlEndPoint, {
|
||||
method: 'POST',
|
||||
requestBody: {
|
||||
method: this.method,
|
||||
request: fireArg,
|
||||
response: null
|
||||
}
|
||||
});
|
||||
return response.body.response;
|
||||
}
|
||||
}
|
||||
export * from './typedrequest.classes.typedrequest';
|
||||
export * from './typedrequest.classes.typedhandler';
|
||||
|
1
ts/typedrequest.classes.typedhandler.ts
Normal file
1
ts/typedrequest.classes.typedhandler.ts
Normal file
@ -0,0 +1 @@
|
||||
export class TypedHandler {}
|
27
ts/typedrequest.classes.typedrequest.ts
Normal file
27
ts/typedrequest.classes.typedrequest.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import * as plugins from './typedrequest.plugins';
|
||||
|
||||
export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest> {
|
||||
public urlEndPoint: string;
|
||||
public method: string;
|
||||
|
||||
// STATIC
|
||||
constructor(urlEndPointArg: string, methodArg: T['method']) {
|
||||
this.urlEndPoint = urlEndPointArg;
|
||||
this.method = methodArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* firest the request
|
||||
*/
|
||||
public async fire(fireArg: T['request']): Promise<T['response']> {
|
||||
const response = await plugins.smartrequest.request(this.urlEndPoint, {
|
||||
method: 'POST',
|
||||
requestBody: {
|
||||
method: this.method,
|
||||
request: fireArg,
|
||||
response: null
|
||||
}
|
||||
});
|
||||
return response.body.response;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user