Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@algolia/transporter

Package Overview
Dependencies
Maintainers
60
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/transporter

Promise-based transporter layer with embedded retry strategy.

  • 4.0.0-beta.10
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5M
decreased by-20.93%
Maintainers
60
Weekly downloads
 
Created

What is @algolia/transporter?

@algolia/transporter is a low-level HTTP client for making requests to Algolia's API. It provides a set of utilities to handle retries, timeouts, and other network-related concerns, making it easier to interact with Algolia's services.

What are @algolia/transporter's main functionalities?

Basic Request

This code demonstrates how to create a basic transporter instance and make a GET request to list all indexes in an Algolia application.

const { createTransporter } = require('@algolia/transporter');

const transporter = createTransporter({
  hosts: [{ url: 'https://your-algolia-instance.algolia.net' }],
  headers: { 'X-Algolia-API-Key': 'your-api-key', 'X-Algolia-Application-Id': 'your-app-id' }
});

transporter.read({ method: 'GET', path: '/1/indexes' }).then(response => {
  console.log(response);
});

Handling Retries

This code shows how to configure the transporter to handle retries with specific timeout settings and retry policies.

const { createTransporter } = require('@algolia/transporter');

const transporter = createTransporter({
  hosts: [{ url: 'https://your-algolia-instance.algolia.net' }],
  headers: { 'X-Algolia-API-Key': 'your-api-key', 'X-Algolia-Application-Id': 'your-app-id' },
  timeouts: { connect: 1, read: 2, write: 30 },
  retry: { maxRetries: 3, delay: 1000 }
});

transporter.read({ method: 'GET', path: '/1/indexes' }).then(response => {
  console.log(response);
});

Custom Headers

This example demonstrates how to add custom headers to the transporter instance for making requests.

const { createTransporter } = require('@algolia/transporter');

const transporter = createTransporter({
  hosts: [{ url: 'https://your-algolia-instance.algolia.net' }],
  headers: { 'X-Algolia-API-Key': 'your-api-key', 'X-Algolia-Application-Id': 'your-app-id', 'Custom-Header': 'custom-value' }
});

transporter.read({ method: 'GET', path: '/1/indexes' }).then(response => {
  console.log(response);
});

Other packages similar to @algolia/transporter

FAQs

Package last updated on 17 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc