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

@mimik/address-helper

v1.6.10

Published

IP Address helper for mimik microservices

Downloads

157

Readme

address-helper

Example

const addressHelper = require('@mimik/address-helper');

address-helper~getAddressByType(type, addresses) ⇒ object

Get the address by type from an array of address.

Kind: inner method of address-helper
Returns: object - Address by type.
Category: sync

| Param | Type | Description | | --- | --- | --- | | type | string | Type of address to return. | | addresses | Array.<object> | Addresses from which the specific address is retrieved. |

address-helper~hrefId(serverSettings, basePath, resource, id) ⇒ URL.<string>

Generate a href based of the given parameters.

Kind: inner method of address-helper
Returns: URL.<string> - Generated href.
Category: sync

| Param | Type | Description | | --- | --- | --- | | serverSettings | object | configuration to use to generate the href. | | basePath | PATH.<string> | Base path to use to generate the href. | | resource | PATH.<string> | Resource to use to generate the href. | | id | UUID.<string> | id to use to generate the href. |

address-helper~addressTypeMaker(type, href, routingPort) ⇒ object

Generate an address using the given parameters.

Kind: inner method of address-helper
Returns: object - Generated address.
Category: sync

| Param | Type | Description | | --- | --- | --- | | type | string | type to use the generate the address to return. | | href | URL.<string> | URL to use to generate the address to return. | | routingPort | number | Routing port to generate the address to return. |

address-helper~addressFormat(type, protocol, ip, port, pathname, routingPort) ⇒ object

Return an address using the given parameters.

Kind: inner method of address-helper
Returns: object - Generated address.
Category: sync

| Param | Type | Description | | --- | --- | --- | | type | string | type to use the generate the address to return. | | protocol | string | protocol to use to generate the address to return. | | ip | IP.<string> | Ip to use to generate the address to return. | | port | number | Port to use to generate the address to return. | | pathname | PATH.<string> | Path to add to generate the address to return. | | routingPort | number | Port to use to set the address to return. |

address-helper~addressFromNode(type, ip, node, routingPort) ⇒ object

Return an address corresponding to the given parameters.

Kind: inner method of address-helper
Summary: If the type is proxy, a inversion using routingPort is done.
Returns: object - Generated address corresponding to the given parameters.
Category: sync

| Param | Type | Description | | --- | --- | --- | | type | string | Type of address to return | | ip | IP.<string> | IP address to used to generate the address to return. | | node | object | Node to use to generate the address to return. | | routingPort | number | Routing port to use to generate the address to return. |

address-helper~getAddress(node, localLinkNetworkId) ⇒ object

Return the address to be used to reach the node.

Kind: inner method of address-helper
Summary: If localLinkNetworkId is present, return the local address. Otherwise return the proxy address, if it exists, or the public address.
Returns: object - Address to use to reach the node.
Category: sync

| Param | Type | Description | | --- | --- | --- | | node | object | Node from which to get the address. | | localLinkNetworkId | string | Id of the link local network to get the address from. |

address-helper~updateAddresses(type, newAddress, addresses) ⇒ Array.<object>

Add a new address of a specific type in the array of addresses.

Kind: inner method of address-helper
Returns: Array.<object> - Updated array of addresses.
Category: sync

| Param | Type | Description | | --- | --- | --- | | type | string | Type of address to add. | | newAddress | object | New address to add the the array of addresses. | | addresses | Array.<object> | Initial array of addresses to which the new address will be added. |

address-helper~publicIpFromNode(node) ⇒ IP.<string>

Get the public IP address from the registering node.

Kind: inner method of address-helper
Summary: If node is not defined return null.
Returns: IP.<string> - Public IP address of the node.
Category: sync

| Param | Type | Description | | --- | --- | --- | | node | object | The node containing the public IP address. |

address-helper~publicIpFromRequest(req) ⇒ IP.<string>

Get the public IP address from the http request.

Kind: inner method of address-helper
Returns: IP.<string> - Public IP address of the component making the request.

| Env variable name | Description | Default | Comments | | ----------------- | ----------- | ------- | -------- | | IPV4 | when existent on non null, will translate an IPV6 address into IPV4 address when possible | | ::1 will be translated to `127.0.0.1``

If the environment variable IPV4 is set to true, the ip address will be translated to IPV4 address when possible, and ::1 will be translated to 127.0.0.1.
Category: sync

| Param | Type | Description | | --- | --- | --- | | req | object | The http request to get the public IP address. |