Skip to content

Commit 6a51895

Browse files
authored
fix: remove type imports from "http" for Deno compatibility (#221)
1 parent a7a293f commit 6a51895

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

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 { parseRequest } from "./parse-request";
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/parse-request.ts

Lines changed: 5 additions & 2 deletions
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
// @ts-ignore remove once Node 10 is out maintenance. Replace with Object.fromEntries
47
import fromEntries from "fromentries";
@@ -41,7 +44,7 @@ export async function parseRequest(
4144
let bodyChunks: Uint8Array[] = [];
4245
request
4346
.on("error", reject)
44-
.on("data", (chunk) => bodyChunks.push(chunk))
47+
.on("data", (chunk: Uint8Array) => bodyChunks.push(chunk))
4548
.on("end", async () => {
4649
const bodyString = Buffer.concat(bodyChunks).toString();
4750
if (!bodyString) return resolve({ headers, query });

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
export type MiddlewareOptions = {
48
pathPrefix?: string;

0 commit comments

Comments
 (0)