11import { WebhookEvent } from "@octokit/webhooks-definitions/schema" ;
22// @ts -ignore to address #245
33import 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
1215export 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 ) ) ;
0 commit comments