Skip to content

Commit 726557d

Browse files
committed
Formatting.
1 parent 6afa4c0 commit 726557d

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

spec/common/providers/https.spec.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -761,25 +761,23 @@ describe("onCallHandler", () => {
761761
it("returns data in SSE format for requests Accept: text/event-stream header", async () => {
762762
const mockReq = mockRequest(
763763
{ message: "hello streaming" },
764-
"application/json", {},
764+
"application/json",
765+
{},
765766
{ accept: "text/event-stream" }
766767
) as any;
767768
const fn = https.onCallHandler(
768769
{
769770
cors: { origin: true, methods: "POST" },
770771
},
771772
(req, resp) => {
772-
resp.write("hello")
773-
return 'world';
773+
resp.write("hello");
774+
return "world";
774775
},
775776
"v2"
776777
);
777778

778779
const resp = await runHandler(fn, mockReq);
779-
const data = [
780-
`data: {"message":"hello"}`,
781-
`data: {"result":"world"}`,
782-
]
780+
const data = [`data: {"message":"hello"}`, `data: {"result":"world"}`];
783781
expect(resp.body).to.equal([...data, ""].join("\n"));
784782
});
785783

@@ -794,16 +792,14 @@ describe("onCallHandler", () => {
794792
{
795793
cors: { origin: true, methods: "POST" },
796794
},
797-
(req, resp) => {
798-
throw new Error("BOOM")
795+
(_req, _resp) => {
796+
throw new Error("BOOM");
799797
},
800798
"v2"
801799
);
802800

803801
const resp = await runHandler(fn, mockReq);
804-
const data = [
805-
`data: {"error":{"message":"INTERNAL","status":"INTERNAL"}}`,
806-
]
802+
const data = [`data: {"error":{"message":"INTERNAL","status":"INTERNAL"}}`];
807803
expect(resp.body).to.equal([...data, ""].join("\n"));
808804
});
809805
});

spec/helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function runHandler(
6868

6969
public send(sendBody: any) {
7070
const toSend = typeof sendBody === "object" ? JSON.stringify(sendBody) : sendBody;
71-
const body = this.sentBody ? this.sentBody + (toSend || "") : toSend;
71+
const body = this.sentBody ? this.sentBody + ((toSend as string) || "") : toSend;
7272

7373
resolve({
7474
status: this.statusCode,

src/common/providers/https.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ function wrapOnCallHandler<Req = any, Res = any>(
804804
};
805805
if (acceptsStreaming) {
806806
// SSE always responds with 200
807-
res.status(200)
807+
res.status(200);
808808
}
809809
// For some reason the type system isn't picking up that the handler
810810
// is a one argument function.
@@ -817,7 +817,7 @@ function wrapOnCallHandler<Req = any, Res = any>(
817817
// If there was some result, encode it in the body.
818818
const responseBody: HttpResponseBody = { result };
819819
if (acceptsStreaming) {
820-
res.write(encodeSSE(responseBody))
820+
res.write(encodeSSE(responseBody));
821821
res.end();
822822
} else {
823823
res.status(200).send(responseBody);

0 commit comments

Comments
 (0)