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

Feat: Add typescript definitions on npm #3

Open
ShivamJoker opened this issue Aug 4, 2023 · 1 comment
Open

Feat: Add typescript definitions on npm #3

ShivamJoker opened this issue Aug 4, 2023 · 1 comment

Comments

@ShivamJoker
Copy link

Hey thanks for the great work you've put out here.
It would be great to get built in types.

@dgrelaud
Copy link
Member

dgrelaud commented Jan 8, 2024

Hello,

Oh yes, it was on my roadmap.
I need some time to do it. Feel free to open a pull request, even if it is not perfect. It will help me a lot.

Here were my initial notes on it:

declare module 'rock-req' {
  import { Agent } from 'http';
  import { RequestOptions as HttpRequestOptions } from 'https';
  import { Writable, Readable } from 'stream';

  export interface RequestOptions extends HttpRequestOptions {
    maxRedirects?: number;
    maxRetry?: number;
    retryDelay?: number;
    keepAliveDuration?: number;
    retryOnCode?: number[];
    retryOnError?: string[];
    beforeRequest?: (options: RequestOptions) => RequestOptions;
    json?: boolean;
    form?: any;
    output?: (options: RequestOptions, response: Response) => Writable;
    remainingRetry?: number;
    remainingRedirects?: number;
    body?: string | Buffer | Readable;
    prevError?: Error;
    prevStatusCode?: number;
  }

  export function rock(opts: RequestOptions | string, directBody?: any, cb?: (err: Error | null, response?: Response, data?: any) => void): any;
  export function extend(defaultOptions?: RequestOptions): typeof rock;

  export interface Rock {
    get: typeof rock;
    post: typeof rock;
  }
}

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