nxtedition/node-http2-proxy

add typescript support

masx200 opened this issue · 3 comments

add typescript support

Only one type declaration file is needed, it should be easier.

declare module "http2-proxy" {
    import * as Http from "http";
    import * as Http2 from "http2";
    import * as Net from "net";

    function web(req: Http.IncomingMessage | Http2.Http2ServerRequest, res: Http.ServerResponse | Http2.Http2ServerResponse, options: webOptions, callback?: (err: Error, req: Http.IncomingMessage | Http2.Http2ServerRequest, res: Http.ServerResponse | Http2.Http2ServerResponse) => void): void

    function ws(req: Http.IncomingMessage | Http2.Http2ServerRequest, socket: Net.Socket, head: Buffer, options: wsOptions, callback?: (err: Error, req: Http.IncomingMessage | Http2.Http2ServerRequest, socket: Net.Socket, head: Buffer) => void): void

    interface options {
        hostname: string;
        port: number;
        protocol?: "http" | "https";
        path?: string;
        proxyTimeout?: number;
        proxyName?: string;

        onReq?(req: Http.IncomingMessage | Http2.Http2ServerRequest, options: Http.RequestOptions, callback: (err?: Error) => void): void;
    }

    interface webOptions extends options {
        onRes?(req: Http.IncomingMessage | Http2.Http2ServerRequest, res: Http.ServerResponse | Http2.Http2ServerResponse, proxyRes: Http.ServerResponse, callback: () => any): void
    }

    interface wsOptions extends options {
        onRes?(req: Http.IncomingMessage | Http2.Http2ServerRequest, socket: Net.Socket, proxyRes: Http.ServerResponse, callback: () => any): void
    }
}

ronag commented

PR is welcome.