Skip to content

Commit 662f35c

Browse files
committed
fix: testing deno compatibility be removing import from "http"
1 parent 38345f8 commit 662f35c

File tree

5 files changed

+30
-12
lines changed

5 files changed

+30
-12
lines changed

src/middleware/node/get-missing-headers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { IncomingMessage } from "http";
1+
// remove type imports from http for Deno compatibility
2+
// see https://github.com/octokit/octokit.js/issues/24#issuecomment-817361886
3+
// import { IncomingMessage } from "http";
4+
type IncomingMessage = any;
25

36
const WEBHOOK_HEADERS = [
47
"x-github-event",

src/middleware/node/get-payload.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { WebhookEvent } from "@octokit/webhooks-definitions/schema";
22
// @ts-ignore to address #245
33
import AggregateError from "aggregate-error";
4-
import { IncomingMessage } from "http";
54

6-
declare module "http" {
7-
interface IncomingMessage {
8-
body?: WebhookEvent;
9-
}
10-
}
5+
// remove type imports from http for Deno compatibility
6+
// see https://github.com/octokit/octokit.js/issues/24#issuecomment-817361886
7+
// import { IncomingMessage } from "http";
8+
// declare module "http" {
9+
// interface IncomingMessage {
10+
// body?: WebhookEvent | unknown;
11+
// }
12+
// }
13+
type IncomingMessage = any;
1114

1215
export function getPayload(request: IncomingMessage): Promise<WebhookEvent> {
1316
// If request.body already exists we can stop here
@@ -21,8 +24,8 @@ export function getPayload(request: IncomingMessage): Promise<WebhookEvent> {
2124
request.setEncoding("utf8");
2225

2326
// istanbul ignore next
24-
request.on("error", (error) => reject(new AggregateError([error])));
25-
request.on("data", (chunk) => (data += chunk));
27+
request.on("error", (error: Error) => reject(new AggregateError([error])));
28+
request.on("data", (chunk: string) => (data += chunk));
2629
request.on("end", () => {
2730
try {
2831
resolve(JSON.parse(data));

src/middleware/node/middleware.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { IncomingMessage, ServerResponse } from "http";
1+
// remove type imports from http for Deno compatibility
2+
// see https://github.com/octokit/octokit.js/issues/24#issuecomment-817361886
3+
// import { IncomingMessage, ServerResponse } from "http";
4+
type IncomingMessage = any;
5+
type ServerResponse = any;
26

37
import { WebhookEventName } from "@octokit/webhooks-definitions/schema";
48

src/middleware/node/on-unhandled-request-default.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { IncomingMessage, ServerResponse } from "http";
1+
// remove type imports from http for Deno compatibility
2+
// see https://github.com/octokit/octokit.js/issues/24#issuecomment-817361886
3+
// import { IncomingMessage, ServerResponse } from "http";
4+
type IncomingMessage = any;
5+
type ServerResponse = any;
26

37
export function onUnhandledRequestDefault(
48
request: IncomingMessage,

src/middleware/node/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { IncomingMessage, ServerResponse } from "http";
1+
// remove type imports from http for Deno compatibility
2+
// see https://github.com/octokit/octokit.js/issues/24#issuecomment-817361886
3+
// import { IncomingMessage, ServerResponse } from "http";
4+
type IncomingMessage = any;
5+
type ServerResponse = any;
26

37
import { Logger } from "../../createLogger";
48

0 commit comments

Comments
 (0)