Global

Methods

createSentryRateLimiter(nowFnopt) → {Object}

Creates a rate limiter for Sentry event reporting, keyed by an arbitrary string (typically the Sentry fingerprint or error message). State lives in a Map per rate limiter instance: one instance per process is the expected usage.
Parameters:
Name Type Attributes Default Description
nowFn function <optional>
Date.now clock function (injectable for tests)
Returns:
Object - rate limiter with one method, shouldReport.

createSentryRateLimiter(nowFnopt) → {Object}

Creates a rate limiter for Sentry event reporting, keyed by an arbitrary string (typically the Sentry fingerprint or error message). State lives in a Map per rate limiter instance: one instance per process is the expected usage.
Parameters:
Name Type Attributes Default Description
nowFn function <optional>
Date.now clock function (injectable for tests)
Returns:
Object - rate limiter with one method, shouldReport.

shouldReport(key, windowMs) → {Object}

Record an event and decide whether it should be reported to Sentry.
Parameters:
Name Type Description
key String rate-limit key; typically the error fingerprint or message so that Sentry grouping lines up with our suppression.
windowMs Number rate-limit window in ms; within this window after a report, subsequent events for the same key are suppressed.
Returns:
Object - when `report` is true, `suppressedCount` is the number of events suppressed for this key since the last report (0 if none were suppressed). When `report` is false, `suppressedCount` is 0 (caller should not surface it).

shouldReport(key, windowMs) → {Object}

Record an event and decide whether it should be reported to Sentry.
Parameters:
Name Type Description
key String rate-limit key; typically the error fingerprint or message so that Sentry grouping lines up with our suppression.
windowMs Number rate-limit window in ms; within this window after a report, subsequent events for the same key are suppressed.
Returns:
Object - when `report` is true, `suppressedCount` is the number of events suppressed for this key since the last report (0 if none were suppressed). When `report` is false, `suppressedCount` is 0 (caller should not surface it).

Type Definitions

callAPIOptions

Call an API. Any headers to forward (that were sent to the request which is calling this function) will be added to the headers specified.

CookieConfig

Properties:
Name Type Attributes Default Description
disabled boolean <optional>
false Adds fastify-cookie plugin
secret string <optional>
A secret to use to secure cookie

HealthCheckConfig

Properties:
Name Type Attributes Default Description
disabled boolean <optional>
false Whether to add a health check endpoint that simply returns 200.
path string <optional>
'/' The path to the health check endpoint.

LatencyTrackerConfig

Properties:
Name Type Attributes Default Description
disabled boolean <optional>
false Whether to record how long from when we start to process a request to when we start to send the response
header string <optional>
'x-latency-ms' response header to send the latency info back in

LoggingConfig

Properties:
Name Type Attributes Default Description
reportAllErrors boolean <optional>
false Whether include all API validation errors in error logging. Recommend to keep it off for production, on for testing.
reportErrorDetail boolean <optional>
false Whether include all details of an error. Recommend to keep it off for remote testing, on for local testing.
sentryDSN String <optional>
The Sentry DSN to report errors to. Deliberate client errors (a RequestError subclass with status < 500) are skipped unless flagged via `RequestError.forceSentry()`; crashes and errors not thrown through the exception classes are always reported.
sentryRateLimiter Object <optional>
Optional rate limiter instance (from createSentryRateLimiter) to control Sentry reporting for errors flagged via `RequestError.rateLimitSentry()`. Defaults to a fresh limiter using the real clock; tests inject one with a controllable clock.
customizePinoOpts function <optional>
An optional function customize the arguments to pass to Pino. Takes as input the options that will be sent to be Pino by default (can be modified). Return the new options.

SwaggerConfig

Properties:
Name Type Attributes Default Description
disabled boolean <optional>
false Whether to disable
servers Array.<string> <optional>
[] The host endpoint (scheme + domain) to send requests to
authHeaders Array.<string> <optional>
[] Authentication headers
routePrefix string <optional>
'/docs' Authentication headers