Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@elastic/transport
Advanced tools
Transport classes and utilities shared among Node.js Elastic client libraries
@elastic/transport is a low-level HTTP transport library for Node.js, designed to be used with Elasticsearch clients. It provides the core functionality for making HTTP requests to Elasticsearch clusters, handling retries, and managing connections.
Basic HTTP Request
This feature allows you to make basic HTTP requests to an Elasticsearch cluster. The code sample demonstrates how to create a Transport instance and make a GET request to the root endpoint of the Elasticsearch cluster.
const { Transport } = require('@elastic/transport');
const transport = new Transport({
node: 'http://localhost:9200'
});
async function makeRequest() {
const response = await transport.request({
method: 'GET',
path: '/'
});
console.log(response.body);
}
makeRequest();
Handling Retries
This feature allows you to configure the number of retries for failed requests. The code sample demonstrates how to set up a Transport instance with a maximum of 3 retries and handle the request failure.
const { Transport } = require('@elastic/transport');
const transport = new Transport({
node: 'http://localhost:9200',
maxRetries: 3
});
async function makeRequest() {
try {
const response = await transport.request({
method: 'GET',
path: '/'
});
console.log(response.body);
} catch (error) {
console.error('Request failed after 3 retries:', error);
}
}
makeRequest();
Connection Pooling
This feature allows you to manage multiple connections to different nodes in an Elasticsearch cluster. The code sample demonstrates how to create a Transport instance with a pool of nodes and make a request.
const { Transport } = require('@elastic/transport');
const transport = new Transport({
nodes: [
'http://localhost:9200',
'http://localhost:9201'
]
});
async function makeRequest() {
const response = await transport.request({
method: 'GET',
path: '/'
});
console.log(response.body);
}
makeRequest();
Axios is a promise-based HTTP client for the browser and Node.js. It provides a simple API for making HTTP requests and handling responses. Compared to @elastic/transport, Axios is more general-purpose and not specifically designed for Elasticsearch.
Got is a human-friendly and powerful HTTP request library for Node.js. It supports retries, connection pooling, and other advanced features. While Got is versatile and robust, it is not specialized for Elasticsearch like @elastic/transport.
Node-fetch is a lightweight module that brings `window.fetch` to Node.js. It is minimalistic and focuses on providing a fetch API in Node.js environments. Unlike @elastic/transport, node-fetch does not include advanced features like retries and connection pooling out of the box.
This is a HTTP transport Node.js library for communicate with Elastic products, like Elasticsearch.
npm install @elastic/transport
NOTE: The minimum supported version of Node.js is v16
.
The client versioning follows the Elastc Stack versioning, this means that major, minor, and patch releases are done following a precise schedule that often does not coincide with the Node.js release times.
To avoid support insecure and unsupported versions of Node.js, the client will drop the support of EOL versions of Node.js between minor releases. Typically, as soon as a Node.js version goes into EOL, the client will continue to support that version for at least another minor release.
Unless you are always using a supported version of Node.js,
we recommend defining the client dependency in your
package.json
with the ~
instead of ^
. In this way, you will lock the
dependency on the minor release and not the major. (for example, ~7.10.0
instead
of ^7.10.0
).
Node.js Version | Node.js EOL date | End of support |
---|---|---|
8.x | December 2019 | 7.11 (early 2021) |
10.x | April 2021 | 7.12 (mid 2021) |
12.x | April 2022 | 8.2 (early 2022) |
14.x | April 2023 | 8.8 (early 2023) |
This software is licensed under the Apache 2 license.
FAQs
Transport classes and utilities shared among Node.js Elastic client libraries
The npm package @elastic/transport receives a total of 369,670 weekly downloads. As such, @elastic/transport popularity was classified as popular.
We found that @elastic/transport demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 66 open source maintainers collaborating on the project.
Did you know?
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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.