npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@adobe/aio-lib-core-networking

v5.0.2

Published

Adobe I/O Lib Core Networking

Downloads

80,425

Readme

Version Downloads/week Node.js CI License Codecov Coverage

Adobe I/O Core Networking Lib

Installing

$ npm install @adobe/aio-lib-core-networking

Usage

  1. Initialize the SDK
const { HttpExponentialBackoff, createFetch } = require('@adobe/aio-lib-core-networking')
const fetchRetry = new HttpExponentialBackoff()
const proxyFetch = createFetch()
  1. Call methods using the initialized SDK

const { HttpExponentialBackoff, createFetch } = require('@adobe/aio-lib-core-networking')
const fetchRetry = new HttpExponentialBackoff()
async function sdkTest() {

  return new Promise((resolve, reject) => {
    fetchRetry.exponentialBackoff(url, requestOptions, retryOptions, retryOn, retryDelay)
    .then((response) => {
      if (!response.ok) {
        throw Error(reduceError(response))
      }
      resolve(response.json())
    })
    .catch(err => {
      reject(
        new codes.ERROR_GET_SOMETHING({ sdkDetails, messageValues: err }))
    })
  }) 
}

let proxyFetch 
// this will get the proxy settings from the the HTTP_PROXY or HTTPS_PROXY environment variables, if set
proxyFetch = createFetch()

// this will use the passed in proxy settings. Embed basic auth in the url, if required
proxyFetch = createFetch({ proxyUrl: 'http://my.proxy:8080' })

// if the proxy settings are not passed in, and not available in the HTTP_PROXY or HTTPS_PROXY environment variables, it falls back to a simple fetch
const simpleFetch = createFetch()

Classes

Functions

Typedefs

HttpExponentialBackoff

This class provides methods to implement fetch with retries. The retries use exponential backoff strategy with defaults set to max of 3 retries and initial Delay as 100ms

Kind: global class

httpExponentialBackoff.exponentialBackoff(url, requestOptions, [retryOptions], [retryOn], [retryDelay]) ⇒ Promise.<Response>

This function will retry connecting to a url end-point, with exponential backoff. Returns a Promise.

Kind: instance method of HttpExponentialBackoff
Returns: Promise.<Response> - Promise object representing the http response

| Param | Type | Description | | --- | --- | --- | | url | string | endpoint url | | requestOptions | object | Request | request options | | [retryOptions] | RetryOptions | (optional) retry options | | [retryOn] | function | Array | (optional) Function or Array. If provided, will be used instead of the default | | [retryDelay] | function | number | (optional) Function or number. If provided, will be used instead of the default |

ProxyFetch

This provides a wrapper for fetch that facilitates proxy auth authorization.

Kind: global class

new ProxyFetch(authOptions)

Initialize this class with Proxy auth options

| Param | Type | Description | | --- | --- | --- | | authOptions | ProxyAuthOptions | the auth options to connect with |

proxyFetch.fetch(resource, options) ⇒ Promise.<Response>

Fetch function, using the configured NTLM Auth options.

Kind: instance method of ProxyFetch
Returns: Promise.<Response> - Promise object representing the http response

| Param | Type | Description | | --- | --- | --- | | resource | string | Request | the url or Request object to fetch from | | options | object | the fetch options |

createFetch([proxyAuthOptions]) ⇒ function

Return the appropriate Fetch function depending on proxy settings.

Kind: global function
Returns: function - the Fetch API function

| Param | Type | Description | | --- | --- | --- | | [proxyAuthOptions] | ProxyAuthOptions | the proxy auth options |

parseRetryAfterHeader(header) ⇒ number

Parse the Retry-After header Spec: https://tools.ietf.org/html/rfc7231#section-7.1.3

Kind: global function
Returns: number - Number of milliseconds to sleep until the next call to getEventsFromJournal

| Param | Type | Description | | --- | --- | --- | | header | string | Retry-After header value |

RetryOptions : object

Fetch Retry Options

Kind: global typedef
Properties

| Name | Type | Description | | --- | --- | --- | | maxRetries | number | the maximum number of retries to try (default:3) | | initialDelayInMillis | number | the initial delay in milliseconds (default:100ms) | | proxy | ProxyAuthOptions | the (optional) proxy auth options |

ProxyAuthOptions : object

Proxy Auth Options

Kind: global typedef
Properties

| Name | Type | Description | | --- | --- | --- | | proxyUrl | string | the proxy's url | | rejectUnauthorized | boolean | set to false to not reject unauthorized server certs |

Debug Logs

LOG_LEVEL=debug <your_call_here>

Prepend the LOG_LEVEL environment variable and debug value to the call that invokes your function, on the command line. This should output a lot of debug data for your SDK calls.

Contributing

Contributions are welcome! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.