Files
shields/module-core_base-service_base-BaseService.html
T

989 lines
20 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: BaseService</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: BaseService</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>
<span class="ancestors"><a href="module-core_base-service_base.html">core/base-service/base</a>~</span>BaseService<span class="signature">()</span><span class="type-signature"></span></h2>
<div class="class-description"><p>Abstract base class which all service classes inherit from.
Concrete implementations of BaseService must implement the methods
category(), route() and handle(namedParams, queryParams)</p></div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="BaseService"><span class="type-signature"></span>new BaseService<span class="signature">()</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_base-service_base.js.html">core/base-service/base.js</a>, <a href="core_base-service_base.js.html#line77">line 77</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="auth"><span class="type-signature">(abstract) </span>auth<span class="type-signature"> :Auth</span></h4>
<div class="description">
<p>Configuration for the authentication helper that prepares credentials
for upstream requests.</p>
<p>See also the config schema in <code>./server.js</code> and <code>doc/server-secrets.md</code>.</p>
<p>To use the configured auth in the handler or fetch method, wrap the
_request() input params in a call to one of:</p>
<ul>
<li>this.authHelper.withBasicAuth()</li>
<li>this.authHelper.withBearerAuthHeader()</li>
<li>this.authHelper.withQueryStringAuth()</li>
</ul>
<p>For example:
this._request(this.authHelper.withBasicAuth({ url, schema, options }))</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Auth</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_base-service_base.js.html">core/base-service/base.js</a>, <a href="core_base-service_base.js.html#line172">line 172</a>
</li></ul></dd>
</dl>
<h4 class="name" id="defaultBadgeData"><span class="type-signature"></span>defaultBadgeData<span class="type-signature"> :DefaultBadgeData</span></h4>
<div class="description">
<p>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.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">DefaultBadgeData</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_base-service_base.js.html">core/base-service/base.js</a>, <a href="core_base-service_base.js.html#line211">line 211</a>
</li></ul></dd>
</dl>
<h4 class="name" id="openApi"><span class="type-signature">(abstract) </span>openApi<span class="type-signature"> :openApiSchema</span></h4>
<div class="description">
<p>An OpenAPI Paths Object describing this service's
route or routes in OpenAPI format.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">openApiSchema</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_base-service_base.js.html">core/base-service/base.js</a>, <a href="core_base-service_base.js.html#line183">line 183</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="https://swagger.io/specification/#paths-object">https://swagger.io/specification/#paths-object</a></li>
<li><a href="module-core_base-service_service-definitions.html#~openApiSchema">module:core/base-service/service-definitions~openApiSchema</a></li>
</ul>
</dd>
</dl>
<h4 class="name" id="routeEnum"><span class="type-signature">(abstract) </span>routeEnum<span class="type-signature"> :Array.&lt;string></span></h4>
<div class="description">
<p>If the route pattern includes an enum, this property should be set to the
array of allowed values. This is used to validate the route pattern and
generate the OpenAPI spec.
enum applies to the first param in the route pattern.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Array.&lt;string></span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_base-service_base.js.html">core/base-service/base.js</a>, <a href="core_base-service_base.js.html#line110">line 110</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".category"><span class="type-signature">(abstract, static) </span>category<span class="type-signature"> :string</span></h4>
<div class="description">
<p>Name of the category to sort this badge into (eg. &quot;build&quot;). Used to sort
the badges on the main shields.io website.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">string</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_base-service_base.js.html">core/base-service/base.js</a>, <a href="core_base-service_base.js.html#line85">line 85</a>
</li></ul></dd>
</dl>
<h4 class="name" id=".route"><span class="type-signature">(abstract, static) </span>route<span class="type-signature"> :Route</span></h4>
<div class="description">
<p>Route to mount this service on</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Route</span>
</li>
</ul>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_base-service_base.js.html">core/base-service/base.js</a>, <a href="core_base-service_base.js.html#line97">line 97</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="handle"><span class="type-signature">(async, abstract) </span>handle<span class="signature">(namedParams, queryParams)</span><span class="type-signature"> &rarr; {Badge}</span></h4>
<div class="description">
<p>Asynchronous function to handle requests for this service. Take the route
parameters (as defined in the <code>route</code> property), perform a request using
<code>this._requestFetcher</code>, and return the badge data.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>namedParams</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><p>Params parsed from route pattern
defined in this.route.pattern or this.route.capture</p></td>
</tr>
<tr>
<td class="name"><code>queryParams</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><p>Params parsed from the query string</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_base-service_base.js.html">core/base-service/base.js</a>, <a href="core_base-service_base.js.html#line356">line 356</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>badge Object validated against serviceDataSchema</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Badge</span>
</dd>
</dl>
<h4 class="name" id=".getEnum"><span class="type-signature">(static) </span>getEnum<span class="signature">(param)</span><span class="type-signature"> &rarr; {Array.&lt;string>}</span></h4>
<div class="description">
<p>If old route enum is used (legacy):
Extract an array of allowed values from this service's route pattern
for a given route parameter</p>
<p>If new routeEnum is used:
Return the array of allowed values for a given route parameter from the
routeEnum property</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>param</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>The name of a param in this service's route pattern</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="core_base-service_base.js.html">core/base-service/base.js</a>, <a href="core_base-service_base.js.html#line124">line 124</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>Array of allowed values for this param</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array.&lt;string></span>
</dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-badge-maker.html">badge-maker</a></li><li><a href="module-badge-maker_lib_xml.html">badge-maker/lib/xml</a></li><li><a href="module-core_base-service_base.html">core/base-service/base</a></li><li><a href="module-core_base-service_base-graphql.html">core/base-service/base-graphql</a></li><li><a href="module-core_base-service_base-json.html">core/base-service/base-json</a></li><li><a href="module-core_base-service_base-jsonl.html">core/base-service/base-jsonl</a></li><li><a href="module-core_base-service_base-svg-scraping.html">core/base-service/base-svg-scraping</a></li><li><a href="module-core_base-service_base-toml.html">core/base-service/base-toml</a></li><li><a href="module-core_base-service_base-xml.html">core/base-service/base-xml</a></li><li><a href="module-core_base-service_base-yaml.html">core/base-service/base-yaml</a></li><li><a href="module-core_base-service_categories.html">core/base-service/categories</a></li><li><a href="module-core_base-service_check-error-response.html">core/base-service/check-error-response</a></li><li><a href="module-core_base-service_errors.html">core/base-service/errors</a></li><li><a href="module-core_base-service_graphql.html">core/base-service/graphql</a></li><li><a href="module-core_base-service_openapi.html">core/base-service/openapi</a></li><li><a href="module-core_base-service_resource-cache.html">core/base-service/resource-cache</a></li><li><a href="module-core_base-service_service-definitions.html">core/base-service/service-definitions</a></li><li><a href="module-core_server_server.html">core/server/server</a></li><li><a href="module-core_service-test-runner_create-service-tester.html">core/service-test-runner/create-service-tester</a></li><li><a href="module-core_service-test-runner_icedfrisby-shields.html">core/service-test-runner/icedfrisby-shields</a></li><li><a href="module-core_service-test-runner_runner.html">core/service-test-runner/runner</a></li><li><a href="module-core_service-test-runner_service-tester.html">core/service-test-runner/service-tester</a></li><li><a href="module-core_service-test-runner_services-for-title.html">core/service-test-runner/services-for-title</a></li><li><a href="module-core_token-pooling_token-pool.html">core/token-pooling/token-pool</a></li><li><a href="module-services_build-status.html">services/build-status</a></li><li><a href="module-services_color-formatters.html">services/color-formatters</a></li><li><a href="module-services_contributor-count.html">services/contributor-count</a></li><li><a href="module-services_date.html">services/date</a></li><li><a href="module-services_downloads.html">services/downloads</a></li><li><a href="module-services_dynamic-common.html">services/dynamic-common</a></li><li><a href="module-services_dynamic_json-path.html">services/dynamic/json-path</a></li><li><a href="module-services_endpoint-common.html">services/endpoint-common</a></li><li><a href="module-services_licenses.html">services/licenses</a></li><li><a href="module-services_package-json-helpers.html">services/package-json-helpers</a></li><li><a href="module-services_php-version.html">services/php-version</a></li><li><a href="module-services_pipenv-helpers.html">services/pipenv-helpers</a></li><li><a href="module-services_route-builder.html">services/route-builder</a></li><li><a href="module-services_size.html">services/size</a></li><li><a href="module-services_steam_steam-base.html">services/steam/steam-base</a></li><li><a href="module-services_test-results.html">services/test-results</a></li><li><a href="module-services_test-validators.html">services/test-validators</a></li><li><a href="module-services_text-formatters.html">services/text-formatters</a></li><li><a href="module-services_validators.html">services/validators</a></li><li><a href="module-services_version.html">services/version</a></li><li><a href="module-services_website-status.html">services/website-status</a></li><li><a href="module-services_winget_version.html">services/winget/version</a></li></ul><h3>Classes</h3><ul><li><a href="BaseThunderstoreService.html">BaseThunderstoreService</a></li><li><a href="module.html#.exports">exports</a></li><li><a href="module-badge-maker_lib_xml.ElementList.html">ElementList</a></li><li><a href="module-badge-maker_lib_xml.XmlElement.html">XmlElement</a></li><li><a href="module-core_base-service_base-graphql-BaseGraphqlService.html">BaseGraphqlService</a></li><li><a href="module-core_base-service_base-jsonl-BaseJsonlService.html">BaseJsonlService</a></li><li><a href="module-core_base-service_base-json-BaseJsonService.html">BaseJsonService</a></li><li><a href="module-core_base-service_base-svg-scraping-BaseSvgScrapingService.html">BaseSvgScrapingService</a></li><li><a href="module-core_base-service_base-toml-BaseTomlService.html">BaseTomlService</a></li><li><a href="module-core_base-service_base-xml-BaseXmlService.html">BaseXmlService</a></li><li><a href="module-core_base-service_base-yaml-BaseYamlService.html">BaseYamlService</a></li><li><a href="module-core_base-service_base-BaseService.html">BaseService</a></li><li><a href="module-core_base-service_errors-ImproperlyConfigured.html">ImproperlyConfigured</a></li><li><a href="module-core_base-service_errors-Inaccessible.html">Inaccessible</a></li><li><a href="module-core_base-service_errors-InvalidParameter.html">InvalidParameter</a></li><li><a href="module-core_base-service_errors-InvalidResponse.html">InvalidResponse</a></li><li><a href="module-core_base-service_errors-NotFound.html">NotFound</a></li><li><a href="module-core_base-service_errors-ShieldsRuntimeError.html">ShieldsRuntimeError</a></li><li><a href="module-core_server_server-Server.html">Server</a></li><li><a href="module-core_service-test-runner_runner-Runner.html">Runner</a></li><li><a href="module-core_service-test-runner_service-tester-ServiceTester.html">ServiceTester</a></li><li><a href="module-core_token-pooling_token-pool-Token.html">Token</a></li><li><a href="module-core_token-pooling_token-pool-TokenPool.html">TokenPool</a></li><li><a href="module-services_route-builder.html">services/route-builder</a></li><li><a href="module-services_steam_steam-base-BaseSteamAPI.html">BaseSteamAPI</a></li></ul><h3>Tutorials</h3><ul><li><a href="tutorial-TUTORIAL.html">TUTORIAL</a></li><li><a href="tutorial-adding-new-config-values.html">adding-new-config-values</a></li><li><a href="tutorial-authentication.html">authentication</a></li><li><a href="tutorial-badge-redirectors.html">badge-redirectors</a></li><li><a href="tutorial-badge-urls.html">badge-urls</a></li><li><a href="tutorial-code-walkthrough.html">code-walkthrough</a></li><li><a href="tutorial-input-validation.html">input-validation</a></li><li><a href="tutorial-json-format.html">json-format</a></li><li><a href="tutorial-performance-testing.html">performance-testing</a></li><li><a href="tutorial-production-hosting.html">production-hosting</a></li><li><a href="tutorial-releases.html">releases</a></li><li><a href="tutorial-retiring-badges.html">retiring-badges</a></li><li><a href="tutorial-self-hosting.html">self-hosting</a></li><li><a href="tutorial-server-secrets.html">server-secrets</a></li><li><a href="tutorial-service-tests.html">service-tests</a></li></ul><h3>Global</h3><ul><li><a href="global.html#_formatLabelForStage">_formatLabelForStage</a></li><li><a href="global.html#assert">assert</a></li><li><a href="global.html#createNumRequestCounter">createNumRequestCounter</a></li><li><a href="global.html#escapeFormat">escapeFormat</a></li><li><a href="global.html#fakeJwtToken">fakeJwtToken</a></li><li><a href="global.html#generateFakeConfig">generateFakeConfig</a></li><li><a href="global.html#generateInstanceId">generateInstanceId</a></li><li><a href="global.html#getBadgeExampleCall">getBadgeExampleCall</a></li><li><a href="global.html#getServiceClassAuthOrigin">getServiceClassAuthOrigin</a></li><li><a href="global.html#getUserAgent">getUserAgent</a></li><li><a href="global.html#legacySonarResponse">legacySonarResponse</a></li><li><a href="global.html#logTrace">logTrace</a></li><li><a href="global.html#noteGithubTokenInvalidation">noteGithubTokenInvalidation</a></li><li><a href="global.html#parseJson">parseJson</a></li><li><a href="global.html#parseJsonl">parseJsonl</a></li><li><a href="global.html#rasterRedirectUrl">rasterRedirectUrl</a></li><li><a href="global.html#testAuth">testAuth</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.5</a> on Sun Aug 09 2026 17:02:01 GMT+0000 (Coordinated Universal Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>