Class: BaseService

core/base-service/base~BaseService()

Abstract base class which all service classes inherit from. Concrete implementations of BaseService must implement the methods category(), route() and handle(namedParams, queryParams)

Constructor

new BaseService()

Source:

Members

(abstract) auth :module:core/base-service/base~Auth

Configuration for the authentication helper that prepares credentials for upstream requests.

See also the config schema in ./server.js and doc/server-secrets.md.

To use the configured auth in the handler or fetch method, wrap the _request() input params in a call to one of:

  • this.authHelper.withBasicAuth()
  • this.authHelper.withBearerAuthHeader()
  • this.authHelper.withQueryStringAuth()

For example: this._request(this.authHelper.withBasicAuth({ url, schema, options }))

Type:
Source:

defaultBadgeData :module:core/base-service/base~DefaultBadgeData

Default data for the badge. These defaults are used if the value is neither included in the service data from the handler nor overridden by the user via query parameters.

Type:
Source:

(abstract) openApi :module:core/base-service/service-definitions~openApiSchema

An OpenAPI Paths Object describing this service's route or routes in OpenAPI format.

Type:
Source:
See:

(abstract, static) category :string

Name of the category to sort this badge into (eg. "build"). Used to sort the badges on the main shields.io website.

Type:
  • string
Source:

(abstract, static) route :module:core/base-service/base~Route

Route to mount this service on

Type:
Source:

Methods

(async, abstract) handle(namedParams, queryParams) → {module:core/base-service/base~Badge}

Asynchronous function to handle requests for this service. Take the route parameters (as defined in the route property), perform a request using this._requestFetcher, and return the badge data.

Parameters:
Name Type Description
namedParams object

Params parsed from route pattern defined in this.route.pattern or this.route.capture

queryParams object

Params parsed from the query string

Source:
Returns:

badge Object validated against serviceDataSchema

Type
module:core/base-service/base~Badge

(static) getEnum(param) → {Array.<string>}

Extract an array of allowed values from this service's route pattern for a given route parameter

Parameters:
Name Type Description
param string

The name of a param in this service's route pattern

Source:
Returns:

Array of allowed values for this param

Type
Array.<string>