Compare commits

...

2 Commits

Author SHA1 Message Date
2fd8219849 1.0.59 2021-11-07 14:56:48 +01:00
ea56e2218f fix(types): better types for TypedRouter.routeAndAddResponse 2021-11-07 14:56:48 +01:00
5 changed files with 6 additions and 5 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@apiglobal/typedrequest",
"version": "1.0.58",
"version": "1.0.59",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@apiglobal/typedrequest",
"version": "1.0.58",
"version": "1.0.59",
"license": "MIT",
"dependencies": {
"@apiglobal/typedrequest-interfaces": "^1.0.15",

View File

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

View File

@ -21,7 +21,7 @@ export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest
public method: string;
/**
* note the overloading is thought to deak with promises
* note the overloading is thought to deal with promises
* @param postEndPointArg
* @param methodArg
*/

View File

@ -91,7 +91,7 @@ export class TypedRouter {
* if typedrequest object has correlation.phase === 'response' -> routes a typed request object to request fire event
* @param typedRequestArg
*/
public async routeAndAddResponse(typedRequestArg: plugins.typedRequestInterfaces.ITypedRequest) {
public async routeAndAddResponse<T extends plugins.typedRequestInterfaces.ITypedRequest = any>(typedRequestArg: T) {
if (!typedRequestArg?.correlation?.phase || typedRequestArg.correlation.phase === 'request') {
const typedHandler = this.getTypedHandlerForMethod(typedRequestArg.method);

View File

@ -6,6 +6,7 @@ export type IPostMethod = (
) => Promise<plugins.typedRequestInterfaces.ITypedRequest>;
/**
* this is an alternative to a post url supplied in `new Typedrequest(new TypedTarget(...), 'someMethodName')`
* enables the use of custom post functions
* used for things like broadcast channels
* e.g. @designestate/dees-comms