From d2fb4a61d016f47dfe65a7f240e83fd6c0f45694 Mon Sep 17 00:00:00 2001 From: wolfy1339 <4595477+wolfy1339@users.noreply.github.com> Date: Tue, 28 Nov 2023 18:24:13 -0500 Subject: [PATCH] refactor: replace NodeJS internal module imports with `node:` specifier imports (#933) * refactor: replace NodeJS internal module imports with `node:` specifier imports * chore: explicitly mark type imports * revert: change mode back to executable --- src/middleware/node/get-missing-headers.ts | 2 +- src/middleware/node/get-payload.ts | 12 ++++++------ src/middleware/node/middleware.ts | 2 +- src/middleware/node/on-unhandled-request-default.ts | 2 +- test/typescript-validate.ts | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/middleware/node/get-missing-headers.ts b/src/middleware/node/get-missing-headers.ts index d7d878d7..8e4b0c32 100644 --- a/src/middleware/node/get-missing-headers.ts +++ b/src/middleware/node/get-missing-headers.ts @@ -1,6 +1,6 @@ // remove type imports from http for Deno compatibility // see https://github.com/octokit/octokit.js/issues/24#issuecomment-817361886 -// import { IncomingMessage } from "http"; +// import type { IncomingMessage } from "node:http"; type IncomingMessage = any; const WEBHOOK_HEADERS = [ diff --git a/src/middleware/node/get-payload.ts b/src/middleware/node/get-payload.ts index 9d1d4909..30c924ad 100644 --- a/src/middleware/node/get-payload.ts +++ b/src/middleware/node/get-payload.ts @@ -2,12 +2,12 @@ import AggregateError from "aggregate-error"; // remove type imports from http for Deno compatibility -// see https://github.com/octokit/octokit.js/issues/24#issuecomment-817361886 -// import { IncomingMessage } from "http"; -// declare module "http" { -// interface IncomingMessage { -// body?: WebhookEvent | unknown; -// } +// see https://github.com/octokit/octokit.js/issues/2075#issuecomment-817361886 +// import type { IncomingMessage } from "node:http"; +// declare module "node:http" { +// interface IncomingMessage { +// body?: string; +// } // } type IncomingMessage = any; diff --git a/src/middleware/node/middleware.ts b/src/middleware/node/middleware.ts index 4947172d..d80246e3 100644 --- a/src/middleware/node/middleware.ts +++ b/src/middleware/node/middleware.ts @@ -1,6 +1,6 @@ // remove type imports from http for Deno compatibility // see https://github.com/octokit/octokit.js/issues/2075#issuecomment-817361886 -// import { IncomingMessage, ServerResponse } from "http"; +// import type { IncomingMessage, ServerResponse } from "node:http"; type IncomingMessage = any; type ServerResponse = any; diff --git a/src/middleware/node/on-unhandled-request-default.ts b/src/middleware/node/on-unhandled-request-default.ts index 367b1c0f..bb064961 100644 --- a/src/middleware/node/on-unhandled-request-default.ts +++ b/src/middleware/node/on-unhandled-request-default.ts @@ -1,6 +1,6 @@ // remove type imports from http for Deno compatibility // see https://github.com/octokit/octokit.js/issues/24#issuecomment-817361886 -// import { IncomingMessage, ServerResponse } from "http"; +// import type { IncomingMessage, ServerResponse } from "node:http"; type IncomingMessage = any; type ServerResponse = any; diff --git a/test/typescript-validate.ts b/test/typescript-validate.ts index 4d76f915..32f5d900 100644 --- a/test/typescript-validate.ts +++ b/test/typescript-validate.ts @@ -5,7 +5,7 @@ import { WebhookError, createNodeMiddleware, } from "../src/index.ts"; -import { createServer } from "http"; +import { createServer } from "node:http"; import type { HandlerFunction, RemoveHandlerFunction,