@godaddy/terminus
Advanced tools
Comparing version 4.6.0 to 4.7.0
@@ -37,4 +37,19 @@ 'use strict' | ||
async function sendFailure (res, options) { | ||
const { error, onSendFailureDuringShutdown } = options | ||
const { error, onSendFailureDuringShutdown, exposeStackTraces } = options | ||
function replaceErrors (_, value) { | ||
if (value instanceof Error) { | ||
const error = {} | ||
Object.getOwnPropertyNames(value).forEach(function (key) { | ||
if (exposeStackTraces !== true && key === 'stack') return | ||
error[key] = value[key] | ||
}) | ||
return error | ||
} | ||
return value | ||
} | ||
if (onSendFailureDuringShutdown) { | ||
@@ -50,3 +65,3 @@ await onSendFailureDuringShutdown() | ||
details: error | ||
})) | ||
}, replaceErrors)) | ||
} | ||
@@ -78,3 +93,3 @@ res.end(FAILURE_RESPONSE) | ||
logger('healthcheck failed', error) | ||
return sendFailure(res, { error: error.causes }) | ||
return sendFailure(res, { error: error.causes, exposeStackTraces: healthChecks.__unsafeExposeStackTraces }) | ||
} | ||
@@ -81,0 +96,0 @@ return sendSuccess(res, { info, verbatim: healthChecks.verbatim }) |
{ | ||
"name": "@godaddy/terminus", | ||
"version": "4.6.0", | ||
"version": "4.7.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -56,3 +56,4 @@ | ||
'/healthcheck': healthCheck, // a function returning a promise indicating service health, | ||
verbatim: true // [optional = false] use object returned from /healthcheck verbatim in response | ||
verbatim: true, // [optional = false] use object returned from /healthcheck verbatim in response, | ||
__unsafeExposeStackTraces: true // [optional = false] return stack traces in error response if healthchecks throw errors | ||
}, | ||
@@ -59,0 +60,0 @@ caseInsensitive, // [optional] whether given health checks routes are case insensitive (defaults to false) |
@@ -11,6 +11,5 @@ declare module "@godaddy/terminus" { | ||
export type HealthCheckMap = { | ||
verbatim?: boolean | ||
__unsafeExposeStackTraces?: boolean; | ||
[key: string]: HealthCheck | boolean; | ||
} | { | ||
verbatim: boolean | ||
[key: string]: HealthCheck | boolean; | ||
} | ||
@@ -17,0 +16,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26453
528
181