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 nowFnfunction <optional>
Date.now clock function (injectable for tests) -
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 nowFnfunction <optional>
Date.now clock function (injectable for tests) -
shouldReport(key, windowMs) → {Object}
-
Record an event and decide whether it should be reported to Sentry.
Parameters:
Name Type Description keyString rate-limit key; typically the error fingerprint or message so that Sentry grouping lines up with our suppression. windowMsNumber 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 keyString rate-limit key; typically the error fingerprint or message so that Sentry grouping lines up with our suppression. windowMsNumber 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 disabledboolean <optional>
false Adds fastify-cookie plugin secretstring <optional>
A secret to use to secure cookie -
HealthCheckConfig
-
Properties:
Name Type Attributes Default Description disabledboolean <optional>
false Whether to add a health check endpoint that simply returns 200. pathstring <optional>
'/' The path to the health check endpoint. -
LatencyTrackerConfig
-
Properties:
Name Type Attributes Default Description disabledboolean <optional>
false Whether to record how long from when we start to process a request to when we start to send the response headerstring <optional>
'x-latency-ms' response header to send the latency info back in -
LoggingConfig
-
Properties:
Name Type Attributes Default Description reportAllErrorsboolean <optional>
false Whether include all API validation errors in error logging. Recommend to keep it off for production, on for testing. reportErrorDetailboolean <optional>
false Whether include all details of an error. Recommend to keep it off for remote testing, on for local testing. sentryDSNString <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. sentryRateLimiterObject <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. customizePinoOptsfunction <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 disabledboolean <optional>
false Whether to disable serversArray.<string> <optional>
[] The host endpoint (scheme + domain) to send requests to authHeadersArray.<string> <optional>
[] Authentication headers routePrefixstring <optional>
'/docs' Authentication headers