diff --git a/src/middleware/node/middleware.ts b/src/middleware/node/middleware.ts index 0166b32ff..2c38fe749 100644 --- a/src/middleware/node/middleware.ts +++ b/src/middleware/node/middleware.ts @@ -1,4 +1,8 @@ -import { IncomingMessage, ServerResponse } from "http"; +// remove type imports from http for Deno compatibility +// see https://github.com/octokit/octokit.js/issues/24#issuecomment-817361886 +// import { IncomingMessage, ServerResponse } from "http"; +type IncomingMessage = any; +type ServerResponse = any; import { parseRequest } from "./parse-request"; diff --git a/src/middleware/node/on-unhandled-request-default.ts b/src/middleware/node/on-unhandled-request-default.ts index c32ef7aac..3664190fc 100644 --- a/src/middleware/node/on-unhandled-request-default.ts +++ b/src/middleware/node/on-unhandled-request-default.ts @@ -1,4 +1,8 @@ -import { IncomingMessage, ServerResponse } from "http"; +// remove type imports from http for Deno compatibility +// see https://github.com/octokit/octokit.js/issues/24#issuecomment-817361886 +// import { IncomingMessage, ServerResponse } from "http"; +type IncomingMessage = any; +type ServerResponse = any; export function onUnhandledRequestDefault( request: IncomingMessage, diff --git a/src/middleware/node/parse-request.ts b/src/middleware/node/parse-request.ts index e57b8252f..da08fbeac 100644 --- a/src/middleware/node/parse-request.ts +++ b/src/middleware/node/parse-request.ts @@ -1,4 +1,7 @@ -import { IncomingMessage } from "http"; +// remove type imports from http for Deno compatibility +// see https://github.com/octokit/octokit.js/issues/24#issuecomment-817361886 +// import { IncomingMessage } from "http"; +type IncomingMessage = any; // @ts-ignore remove once Node 10 is out maintenance. Replace with Object.fromEntries import fromEntries from "fromentries"; @@ -41,7 +44,7 @@ export async function parseRequest( let bodyChunks: Uint8Array[] = []; request .on("error", reject) - .on("data", (chunk) => bodyChunks.push(chunk)) + .on("data", (chunk: Uint8Array) => bodyChunks.push(chunk)) .on("end", async () => { const bodyString = Buffer.concat(bodyChunks).toString(); if (!bodyString) return resolve({ headers, query }); diff --git a/src/middleware/node/types.ts b/src/middleware/node/types.ts index fa4eada2b..6ff8c8ebd 100644 --- a/src/middleware/node/types.ts +++ b/src/middleware/node/types.ts @@ -1,4 +1,8 @@ -import { IncomingMessage, ServerResponse } from "http"; +// remove type imports from http for Deno compatibility +// see https://github.com/octokit/octokit.js/issues/24#issuecomment-817361886 +// import { IncomingMessage, ServerResponse } from "http"; +type IncomingMessage = any; +type ServerResponse = any; export type MiddlewareOptions = { pathPrefix?: string;