Skip to content

Commit

Permalink
fix: remove type imports from "http" for Deno compatibility (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
laughedelic authored Apr 17, 2021
1 parent a7a293f commit 6a51895
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/middleware/node/middleware.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
6 changes: 5 additions & 1 deletion src/middleware/node/on-unhandled-request-default.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
7 changes: 5 additions & 2 deletions src/middleware/node/parse-request.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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 });
Expand Down
6 changes: 5 additions & 1 deletion src/middleware/node/types.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 6a51895

Please sign in to comment.