Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript-Types #17

Closed
Muhaah opened this issue Dec 2, 2017 · 1 comment
Closed

TypeScript-Types #17

Muhaah opened this issue Dec 2, 2017 · 1 comment

Comments

@Muhaah
Copy link

Muhaah commented Dec 2, 2017

Great lib!!
I'm using it now instead of node-http-proxy.
But I love TypeScript so here are the definition file, maybe you can at it inside your lib.

THX

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) => Function): Promise<Error>

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

    interface options {
        hostname: string;
        port: number;
        proxyTimeout?: number;
        proxyName?: string;
        timeout?: Http.IncomingMessage | Http2.Http2ServerRequest;

        onReq?(req: Http.IncomingMessage, options: Http.RequestOptions): void;
    }

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

    interface wsOptions extends options{
        onRes?(req: Http.IncomingMessage | Http2.Http2ServerRequest, socket: Net.Socket): void
    }
}
@ronag
Copy link
Member

ronag commented Dec 17, 2017

Please PR.

@ronag ronag closed this as completed Dec 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants