typed-rest-client

  • Version 2.0.0
  • Published
  • 156 kB
  • 5 dependencies
  • MIT license

Install

npm i typed-rest-client
yarn add typed-rest-client
pnpm add typed-rest-client

Overview

Node Rest and Http Clients for use with TypeScript

Index

Classes

class RestClient

class RestClient {}

    constructor

    constructor(
    userAgent: string,
    baseUrl?: string,
    handlers?: ifm.IRequestHandler[],
    requestOptions?: ifm.IRequestOptions
    );
    • Creates an instance of the RestClient

      Parameter userAgent

      userAgent for requests

      Parameter baseUrl

      (Optional) If not specified, use full urls per request. If supplied and a function passes a relative url, it will be appended to this

      Parameter handlers

      handlers are typically auth handlers (basic, bearer, ntlm supplied)

      Parameter requestOptions

      options for each http requests (http proxy setting, socket timeout)

    property client

    client: httpm.HttpClient;

      property versionParam

      versionParam: string;

        method create

        create: <T>(
        resource: string,
        resources: any,
        options?: IRequestOptions
        ) => Promise<IRestResponse<T>>;
        • Creates resource(s) from an endpoint T type of object returned. Be aware that not found returns a null. Other error conditions reject the promise

          Parameter resource

          fully qualified or relative url

          Parameter requestOptions

          (optional) requestOptions object

        method del

        del: <T>(
        resource: string,
        options?: IRequestOptions
        ) => Promise<IRestResponse<T>>;
        • Deletes a resource from an endpoint Be aware that not found returns a null. Other error conditions reject the promise

          Parameter resource

          fully qualified or relative url

          Parameter requestOptions

          (optional) requestOptions object

        method get

        get: <T>(
        resource: string,
        options?: IRequestOptions
        ) => Promise<IRestResponse<T>>;
        • Gets a resource from an endpoint Be aware that not found returns a null. Other error conditions reject the promise

          Parameter resource

          fully qualified url or relative path

          Parameter requestOptions

          (optional) requestOptions object

        method options

        options: <T>(
        requestUrl: string,
        options?: IRequestOptions
        ) => Promise<IRestResponse<T>>;
        • Gets a resource from an endpoint Be aware that not found returns a null. Other error conditions reject the promise

          Parameter requestUrl

          fully qualified or relative url

          Parameter requestOptions

          (optional) requestOptions object

        method processResponse

        protected processResponse: <T>(
        res: httpm.HttpClientResponse,
        options: IRequestOptions
        ) => Promise<IRestResponse<T>>;

          method replace

          replace: <T>(
          resource: string,
          resources: any,
          options?: IRequestOptions
          ) => Promise<IRestResponse<T>>;
          • Replaces resource(s) from an endpoint T type of object returned. Be aware that not found returns a null. Other error conditions reject the promise

            Parameter resource

            fully qualified or relative url

            Parameter requestOptions

            (optional) requestOptions object

          method update

          update: <T>(
          resource: string,
          resources: any,
          options?: IRequestOptions
          ) => Promise<IRestResponse<T>>;
          • Updates resource(s) from an endpoint T type of object returned. Be aware that not found returns a null. Other error conditions reject the promise

            Parameter resource

            fully qualified or relative url

            Parameter requestOptions

            (optional) requestOptions object

          method uploadStream

          uploadStream: <T>(
          verb: string,
          requestUrl: string,
          stream: NodeJS.ReadableStream,
          options?: IRequestOptions
          ) => Promise<IRestResponse<T>>;

            Interfaces

            interface IRequestOptions

            interface IRequestOptions {}

              property acceptHeader

              acceptHeader?: string;

                property additionalHeaders

                additionalHeaders?: ifm.IHeaders;

                  property deserializeDates

                  deserializeDates?: boolean;

                    property queryParameters

                    queryParameters?: ifm.IRequestQueryParams;

                      property responseProcessor

                      responseProcessor?: Function;

                        interface IRestResponse

                        interface IRestResponse<T> {}

                          property headers

                          headers: Object;

                            property result

                            result: T | null;

                              property statusCode

                              statusCode: number;

                                Package Files (1)

                                Dependencies (5)

                                Dev Dependencies (9)

                                Peer Dependencies (0)

                                No peer dependencies.

                                Badge

                                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/typed-rest-client.

                                • Markdown
                                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/typed-rest-client)
                                • HTML
                                  <a href="https://www.jsdocs.io/package/typed-rest-client"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>