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, 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:

(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) examples :Array.<module:core/base-service/base~Example>

Array of Example objects describing example URLs for this service. These should use the format specified in route, and can be used to demonstrate how to use badges for this service.

The preferred way to specify an example is with namedParams which are substituted into the service's compiled route pattern. The rendered badge is specified with staticPreview.

For services which use a route format, the pattern can be specified as part of the example.

Type:
Source:
See:

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