express-service-readiness-middleware
Advanced tools
Comparing version 1.0.19 to 1.0.20
@@ -15,2 +15,4 @@ import { NextFunction, Request, Response } from "express"; | ||
whitelistedPaths?: string[]; | ||
/** indicates whether critical dependency information should be logged out if critical dependencies fail to become ready */ | ||
logOutCriticalDependenciesOnFailure?: boolean; | ||
} | ||
@@ -17,0 +19,0 @@ /** Dependency interface */ |
@@ -7,3 +7,4 @@ "use strict"; | ||
maximumWaitTimeForServiceReadinessInMilliseconds: 30000, | ||
whitelistedPaths: [] | ||
whitelistedPaths: [], | ||
logOutCriticalDependenciesOnFailure: true | ||
}; | ||
@@ -118,8 +119,21 @@ const dependencyStateItems = []; | ||
}; | ||
const maximumWaitTimeExceeded = () => { | ||
(0, exports.stopCheckingReadiness)(); | ||
informationLogger?.log('All critical dependencies did not become healthy'); | ||
// @ts-ignore | ||
if (global.ExpressServiceReadinessTests === undefined) | ||
process.exit(1); | ||
const maximumWaitTimeExceeded = (config) => { | ||
return () => { | ||
(0, exports.stopCheckingReadiness)(); | ||
const items = []; | ||
dependencyStateItems.forEach(item => { | ||
items.push({ | ||
name: item.name, | ||
data: item.data, | ||
ready: item.ready | ||
}); | ||
}); | ||
if (informationLogger) { | ||
const suffix = config.logOutCriticalDependenciesOnFailure === true ? ` Critical dependencies: ${JSON.stringify(items)}` : ''; | ||
informationLogger?.log(`All critical dependencies did not become healthy.${suffix}`); | ||
} | ||
// @ts-ignore | ||
if (global.ExpressServiceReadinessTests === undefined) | ||
process.exit(1); | ||
}; | ||
}; | ||
@@ -133,3 +147,3 @@ const checkServiceReadiness = (dependencies, config) => { | ||
const maximumWaitTimeForServiceReadinessInMilliseconds = config.maximumWaitTimeForServiceReadinessInMilliseconds ?? DefaultConfig.maximumWaitTimeForServiceReadinessInMilliseconds; | ||
maximumWaitTimeTimeout = setTimeout(maximumWaitTimeExceeded, maximumWaitTimeForServiceReadinessInMilliseconds); | ||
maximumWaitTimeTimeout = setTimeout(maximumWaitTimeExceeded(config), maximumWaitTimeForServiceReadinessInMilliseconds); | ||
criticalDependencies.forEach(criticalDependencies => { | ||
@@ -136,0 +150,0 @@ const { name, data, isReady } = criticalDependencies; |
{ | ||
"name": "express-service-readiness-middleware", | ||
"version": "1.0.19", | ||
"version": "1.0.20", | ||
"description": "This module provides express middleware for determining whether routes are exposed based on service critical dependency health.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -19,3 +19,3 @@ | ||
```bash | ||
$ npm install express-service-readiness-middleware@1.0.19 --save | ||
$ npm install express-service-readiness-middleware@1.0.20 --save | ||
``` | ||
@@ -22,0 +22,0 @@ |
Sorry, the diff of this file is not supported yet
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
24156
279