How to use @algolia/requester-common - 10 common examples

To help you get started, we’ve selected a few @algolia/requester-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / clearSynonyms.ts View on Github external
return (
    requestOptions?: ClearSynonymsOptions & RequestOptions
  ): Readonly> => {
    const { forwardToReplicas, ...options } = requestOptions || {};

    const mappedRequestOptions = createMappedRequestOptions(options);
    if (forwardToReplicas) {
      mappedRequestOptions.queryParameters.forwardToReplicas = 1; // eslint-disable-line functional/immutable-data
    }

    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Post,
          path: encode('1/indexes/%s/synonyms/clear', base.indexName),
        },
        mappedRequestOptions
      ),
      (response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / clearRules.ts View on Github external
return (
    requestOptions?: RequestOptions & ClearRulesOptions
  ): Readonly> => {
    const { forwardToReplicas, ...options } = requestOptions || {};
    const mappedRequestOptions = createMappedRequestOptions(options);
    if (forwardToReplicas) {
      mappedRequestOptions.queryParameters.forwardToReplicas = 1; // eslint-disable-line functional/immutable-data
    }

    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Post,
          path: encode('1/indexes/%s/rules/clear', base.indexName),
        },
        mappedRequestOptions
      ),
      (response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / client / listUserIDs.ts View on Github external
requestOptions?: ListUserIDsOptions & RequestOptions
  ): Readonly> => {
    const { page, hitsPerPage, ...options } = requestOptions || {};
    const mappedRequestOptions = createMappedRequestOptions(options);

    if (page) {
      mappedRequestOptions.queryParameters.page = page; // eslint-disable-line functional/immutable-data
    }

    if (hitsPerPage) {
      mappedRequestOptions.queryParameters.hitsPerPage = hitsPerPage; // eslint-disable-line functional/immutable-data
    }

    return base.transporter.read(
      {
        method: MethodEnum.Get,
        path: '1/clusters/mapping',
      },
      mappedRequestOptions
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / client / getLogs.ts View on Github external
if (length) {
      mappedRequestOptions.queryParameters.length = length; // eslint-disable-line functional/immutable-data
    }

    if (offset) {
      mappedRequestOptions.queryParameters.offset = offset; // eslint-disable-line functional/immutable-data
    }

    if (type) {
      mappedRequestOptions.queryParameters.type = type; // eslint-disable-line functional/immutable-data
    }

    return base.transporter.read(
      {
        method: MethodEnum.Get,
        path: '1/logs',
      },
      mappedRequestOptions
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / getObject.ts View on Github external
return (
    objectID: string,
    requestOptions?: RequestOptions & GetObjectOptions
  ): Readonly> => {
    const { attributesToRetrieve, ...options } = requestOptions || {};
    const mappedRequestOptions = createMappedRequestOptions(options);
    if (attributesToRetrieve) {
      mappedRequestOptions.queryParameters.attributesToRetrieve = attributesToRetrieve; // eslint-disable-line functional/immutable-data
    }

    return base.transporter.read(
      {
        method: MethodEnum.Get,
        path: encode('1/indexes/%s/%s', base.indexName, objectID),
      },
      mappedRequestOptions
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / getSettings.ts View on Github external
return (requestOptions?: RequestOptions): Readonly> => {
    const mappedRequestOptions = createMappedRequestOptions(requestOptions);

    // eslint-disable-next-line functional/immutable-data
    mappedRequestOptions.queryParameters.getVersion = '2';

    return base.transporter.read(
      {
        method: MethodEnum.Get,
        path: encode('1/indexes/%s/settings', base.indexName),
      },
      mappedRequestOptions
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / client / removeUserID.ts View on Github external
return (
    userID: string,
    requestOptions?: RequestOptions
  ): Readonly> => {
    const mappedRequestOptions = createMappedRequestOptions(requestOptions);

    // eslint-disable-next-line functional/immutable-data
    mappedRequestOptions.headers['X-Algolia-User-ID'] = userID;

    return base.transporter.write(
      {
        method: MethodEnum.Delete,
        path: '1/clusters/mapping',
      },
      mappedRequestOptions
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / deleteRule.ts View on Github external
return (
    objectID: string,
    requestOptions?: RequestOptions
  ): Readonly> => {
    const { forwardToReplicas, ...options } = requestOptions || {};

    const mappedRequestOptions = createMappedRequestOptions(options);
    if (forwardToReplicas) {
      mappedRequestOptions.queryParameters.forwardToReplicas = 1; // eslint-disable-line functional/immutable-data
    }

    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Delete,
          path: encode('1/indexes/%s/rules/%s', base.indexName, objectID),
        },
        mappedRequestOptions
      ),
      (response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / deleteSynonym.ts View on Github external
return (
    objectID: string,
    requestOptions?: RequestOptions & DeleteSynonymOptions
  ): Readonly> => {
    const { forwardToReplicas, ...options } = requestOptions || {};

    const mappedRequestOptions = createMappedRequestOptions(options);
    if (forwardToReplicas) {
      mappedRequestOptions.queryParameters.forwardToReplicas = 1; // eslint-disable-line functional/immutable-data
    }

    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Delete,
          path: encode('1/indexes/%s/synonyms/%s', base.indexName, objectID),
        },
        mappedRequestOptions
      ),
      (response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / setSettings.ts View on Github external
return (
    settings: Settings,
    requestOptions?: RequestOptions & SetSettingsOptions
  ): Readonly> => {
    const { forwardToReplicas, ...options } = requestOptions || {};
    const mappedRequestOptions = createMappedRequestOptions(options);

    if (forwardToReplicas) {
      mappedRequestOptions.queryParameters.forwardToReplicas = 1; // eslint-disable-line functional/immutable-data
    }

    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Put,
          path: encode('1/indexes/%s/settings', base.indexName),
          data: settings,
        },
        mappedRequestOptions
      ),
      (response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
    );
  };
};

@algolia/requester-common

Common interfaces for promise-based request libraries

MIT
Latest version published 5 months ago

Package Health Score

80 / 100
Full package analysis

Similar packages