Skip to content

Commit a7fc05f

Browse files
committed
Producer|FunctionEndpoint.invoke() never return undefined
1 parent 66f5222 commit a7fc05f

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

endpoints/rpc/FunctionEndpoint.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { RpcEndpointBase } from ".";
22
import { Endpoint } from "../Endpoint";
3-
import { HttpMethod, HttpHeader, HttpStatusCode } from "../../http";
3+
import { HttpMethod, HttpHeader } from "../../http";
44

55
/**
66
* RPC endpoint that takes `TEntity` as input and returns `TResult` as output when invoked.
@@ -26,13 +26,11 @@ export class FunctionEndpoint<TEntity, TResult> extends RpcEndpointBase {
2626
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
2727
* @throws {@link HttpError}: Other non-success status code
2828
*/
29-
async invoke(entity: TEntity): Promise<(TResult | void)> {
29+
async invoke(entity: TEntity): Promise<TResult> {
3030
const response = await this.send(HttpMethod.Post, {
3131
[HttpHeader.ContentType]: this.serializer.supportedMediaTypes[0]
3232
}, this.serializer.serialize(entity));
3333

34-
return (response.status === HttpStatusCode.OK || response.status === HttpStatusCode.Accepted)
35-
? this.serializer.deserialize<TResult>(await response.text())
36-
: Promise.resolve();
34+
return this.serializer.deserialize<TResult>(await response.text());
3735
}
3836
}

endpoints/rpc/ProducerEndpoint.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { RpcEndpointBase } from ".";
22
import { Endpoint } from "../Endpoint";
3-
import { HttpMethod, HttpStatusCode } from "../../http";
3+
import { HttpMethod } from "../../http";
44

55
/**
66
* RPC endpoint that returns `TResult` as output when invoked.
@@ -24,10 +24,8 @@ export class ProducerEndpoint<TResult> extends RpcEndpointBase {
2424
* @throws {@link NotFoundError}: {@link HttpStatusCode.NotFound} or {@link HttpStatusCode.Gone}
2525
* @throws {@link HttpError}: Other non-success status code
2626
*/
27-
async invoke(): Promise<(TResult | void)> {
27+
async invoke(): Promise<TResult> {
2828
const response = await this.send(HttpMethod.Post);
29-
return (response.status === HttpStatusCode.OK || response.status === HttpStatusCode.Accepted)
30-
? this.serializer.deserialize<TResult>(await response.text())
31-
: Promise.resolve();
29+
return this.serializer.deserialize<TResult>(await response.text());
3230
}
3331
}

0 commit comments

Comments
 (0)