Compare commits

...

2 Commits

Author SHA1 Message Date
78e8171a6a 1.0.47 2020-10-06 14:29:50 +00:00
c97a535035 fix(core): update 2020-10-06 14:29:49 +00:00
3 changed files with 14 additions and 6 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@apiglobal/typedrequest",
"version": "1.0.46",
"version": "1.0.47",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@apiglobal/typedrequest",
"version": "1.0.46",
"version": "1.0.47",
"private": false,
"description": "make typed requests towards apis",
"main": "dist_ts/index.js",

View File

@ -4,7 +4,11 @@ import { TypedRouter } from './typedrequest.classes.typedrouter';
export type IPostMethod = (
typedRequestPostObject: plugins.typedRequestInterfaces.ITypedRequest
) => void | Promise<plugins.typedRequestInterfaces.ITypedRequest>;
) => Promise<plugins.typedRequestInterfaces.ITypedRequest>;
export type IPostMethodWithTypedRouter = (
typedRequestPostObject: plugins.typedRequestInterfaces.ITypedRequest
) => Promise<void> | Promise<plugins.typedRequestInterfaces.ITypedRequest>;
export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest> {
/**
@ -21,15 +25,19 @@ export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest
/**
* in case we post with some other method, ec ipc communication
*/
public postMethod?: IPostMethod;
public postMethod?: IPostMethod | IPostMethodWithTypedRouter;
public method: string;
// STATIC
constructor(
postEndPointArg: string | IPostMethod,
methodArg: T['method']
)
constructor(
postEndPointArg: string | IPostMethodWithTypedRouter,
methodArg: T['method'],
typedrouterRefArg?: TypedRouter
) {
typedrouterRefArg?: TypedRouter)
{
if (typeof postEndPointArg === 'string') {
this.urlEndPoint = postEndPointArg;
} else {