Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-service-readiness-middleware

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-service-readiness-middleware - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

11

dist/lib/index.d.ts

@@ -33,2 +33,11 @@ import { NextFunction, Request, Response } from "express";

}
/** Dependencies Health interface */
export interface IDependenciesHealth {
/** indicates whether all dependencies are healthy */
allDependenciesHealthy: boolean;
/** indicates whether all critical dependencies are healthy */
allCriticalDependenciesHealthy: boolean;
/** health information about all dependencies */
dependencies: IDependencyHealth[];
}
/** Dependency health interface */

@@ -62,3 +71,3 @@ export interface IDependencyHealth {

*/
export declare const checkDependenciesHealth: (dependencies: IDependency[]) => Promise<IDependencyHealth[]>;
export declare const checkDependenciesHealth: (dependencies: IDependency[]) => Promise<IDependenciesHealth>;
/**

@@ -65,0 +74,0 @@ * Set a logger

@@ -49,2 +49,4 @@ "use strict";

const promises = [];
let allDependenciesHealthy = true;
let allCriticalDependenciesHealthy = true;
for (const dependency of dependencies) {

@@ -57,10 +59,20 @@ promises.push(checkDependencyHealth(dependency));

const promiseResult = promiseResults[i];
const healthy = promiseResult.status === 'fulfilled' && promiseResult.value;
dependenciesHealth.push({
name: dependency.name,
data: dependency.data,
healthy: promiseResult.status === 'fulfilled' && promiseResult.value,
healthy,
critical: dependency.critical
});
if (!healthy) {
allDependenciesHealthy = false;
if (dependency.critical)
allCriticalDependenciesHealthy = false;
}
}
return dependenciesHealth;
return {
allDependenciesHealthy,
allCriticalDependenciesHealthy,
dependencies: dependenciesHealth
};
};

@@ -67,0 +79,0 @@ exports.checkDependenciesHealth = checkDependenciesHealth;

2

package.json
{
"name": "express-service-readiness-middleware",
"version": "1.0.10",
"version": "1.0.11",
"description": "This module provides express middleware for determining whether routes are exposed based on service critical dependency health.",

@@ -5,0 +5,0 @@ "repository": {

@@ -26,3 +26,3 @@

createReadinessMiddleware,
criticalDependenciesReady
criticalDependenciesReady,
setLogger

@@ -48,5 +48,17 @@ } = require('express-service-readiness-middleware')

^^ would output:
{
"name": "dependency-one", "critical": true, "data": { "connectionString": "protocol:://{user}:{password}/test", }, "healthy": true}
*/
{
"allDependenciesHealthy": true,
"allCriticalDependenciesHealthy": true,
"dependencies": [
{
name": "dependency-one",
"critical": true,
"data": {
"connectionString": "protocol:://{user}:{password}/test", },
"healthy": true
}
}
]
}
*/

@@ -86,6 +98,25 @@ // check whether all critical dependencies are ready

The `checkDependenciesHealth` will check all dependencies health and return a result. `isHealthy` will be used if defined on a dependency otherwise it will fallback to `isReady`.
The `checkDependenciesHealth` will check all dependencies health and return a result. `isHealthy` will be used if defined on a dependency otherwise it will fall back to `isReady`.
```js
const health = await checkDependenciesHealth(dependencies)
const health = await checkDependenciesHealth(dependencies)
console.log(JSON.stringify(health, null, 2))
/*
^^ would output:
{
"allDependenciesHealthy": true,
"allCriticalDependenciesHealthy": true,
"dependencies": [
{
name": "dependency-one",
"critical": true,
"data": {
"connectionString": "protocol:://{user}:{password}/test", },
"healthy": true
}
}
]
}
*/
```

@@ -92,0 +123,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc