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 :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:
  • Auth
Source:

defaultBadgeData :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:
  • DefaultBadgeData
Source:

(abstract) openApi :openApiSchema

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

Type:
  • openApiSchema
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 :Route

Route to mount this service on

Type:
  • Route
Source:

Methods

(async, abstract) handle(namedParams, queryParams) → {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
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>