Module: services/endpoint-common

Common functions and utilities for tasks related to endpoint badges.

Source:

Members

(inner, constant) endpointSchema :Joi

Joi schema for validating endpoint.

Type:
  • Joi
Source:

Methods

(async, inner) fetchEndpointData(serviceInstance, attrs) → {object}

Fetches data from the endpoint and validates the data.

Parameters:
Name Type Description
serviceInstance object

Instance of Endpoint class

attrs object

Refer to individual attributes

Properties
Name Type Description
url string

Endpoint URL

httpErrors object

Object containing error messages for different error codes

validationPrettyErrorMessage string

If provided then the error message is set to this value

includeKeys boolean

If true then includes error details in error message

Source:
Returns:

Data fetched from endpoint

Type
object

(inner) validateEndpointData(data, attrs) → {object}

Strictly validate the data according to the endpoint schema. This rejects unknown/invalid keys. Optionally it prints those keys in the message to provide detailed feedback.

Parameters:
Name Type Description
data object

Object containing the data for validation

attrs object

Refer to individual attributes

Properties
Name Type Attributes Description
prettyErrorMessage string <optional>

If provided then error message is set to this value

includeKeys boolean <optional>

If true then includes error details in error message, defaults to false

Source:
Throws:

Error if Joi validation fails due to invalid or no schema

Type
InvalidResponse | Error
Returns:

Value if Joi validation is success

Type
object