2.0.1 • Published 2 years ago

@mimik/public-helper v2.0.1

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
2 years ago

public-helper

Example

const publicHlelper = require('@mimik/public-helper');

module.exports ⏏

To note

The following environment variables are required for custom locations:

Env variable nameExampleComments
LOCATION_PROVIDERenvironmentFor custom location, value for this var should be set to "environment"
SERVER_PUBLIC_IPV452.84.158.59
SERVER_LOCATION_LON-122.676
SERVER_LOCATION_LAT45.5235

Kind: Exported member

module.exports~PROPERTIES

Property associated with the location.

The following environment variables are set:

Env variable nameDescriptionDefaultComments
query1query to fill the different local properties from AWSSERVER_LOCAL_IPV4, INSTANCE_ID, LOCAL_HOSTNAME
publicQuery1publicQuery to fill the public property from AWSSERVER_PUBLIC_IPV4

The following environment variables are used:

Env variable nameDescriptionDefaultComments
AWS_LOCAL_PROPERTIESIP address to access instance properties on AWS169.254.169.254

Kind: inner constant of module.exports

module.exports~getLocation(}, ip, correlationId, options) ⇒ Promise

The location object has the follwoing structure:

 {
   "type": "Point",
   "coordinates": [ lon, lat],
   .....
 }

The result object has the following structure:

 {
   "status": (describing where the data come from),
   "ip": (the public IP address of the server),
   "location": (the location object)
 }

When ip is not present, the following environement variables will be updated:

Env variable nameDescriptionDefaultComments
SERVER_LOCATION_LONlongitude of the IP addresslocation.coordinates0
SERVER_LOCATION_LATlatitude of the IP addresslocation.coordinates1
SERVER_PUBLIC_IPV4public IP addressresult.ip

Kind: inner method of module.exports
Returns: Promise - .
Category: async
Fulfil: object The location object encapsulated in the result.

ParamTypeDescription
}objectlocationProvider - location provider information to use for getting the location { url, key } (key is optional).
ipIP.<string>Optional IP address to locate.
correlationIdstringCorrelation Id to add the the request.
optionsobjectOptions associated with the call. Use to pass metrics to rpRetry.

module.exports~getPublic(locationProvider, cloudProvider, correlationId, options) ⇒ Promise

The location data has the following structure:

 {
   "status": (describing where the data come from),
   "ip": (the public IP address of the server),
   "localIp": (`in case of AWS` local adddress),
   "instanceId": (`in case of AWS` id of the instance running the service),
   "location": (the location object)
 }

When provided, the locationProvider information has the following stucture:

 {
   "url": (URL of the provider),
   "key": (security key to associated with the request)
 }

The following environment variables will used:

Env variable nameDescriptionDefaultComments
SERVER_LOCAL_IPV4AWS local IP address
INSTANCE_IDid of the instance
SERVER_PUBLIC_IPV4public IP address
SERVER_IDid of the server
SERVER_LOCATION_LONlongitude of the server
SERVER_LOCATION_LATlatitude of the server

and in order to set these properties process.env.AWS_LOCAL_PROPERTIES is used and is default 169.254.169.254 is used.

Kind: inner method of module.exports
Returns: Promise - .
Category: async
Fulfil: object The location data.

ParamTypeDescription
locationProviderURL.<string>The location provider or noPublic when no locationProvider is used or environment when the environment variables have the information.
cloudProviderstringCloud Provider used to run the service (currently limited to AWS).
correlationIdstringCorrelation Id to add the the request.
optionsobjectOptions associated with the call. Use to pass metrics to rpRetry.

module.exports~setSettings(settings, newConfig) ⇒ object

Set config.serverSettings with location data.

Kind: inner method of module.exports
Returns: object - The updated config.serverSettings.
Category: sync

ParamTypeDescription
settingsobjectThe config.serverSettings to update.
newConfigobjectThe location configuration to use to update the config.serverSettings.
2.0.1

2 years ago

2.0.0

2 years ago

1.5.5

3 years ago

1.6.2

2 years ago

1.6.1

2 years ago

1.6.0

3 years ago

1.5.6

3 years ago

1.5.4

3 years ago

1.5.3

4 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

7 years ago

1.2.0

7 years ago