Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@qiwi/health-indicator
Advanced tools
Health indicator kit for server-side monitoring & balancing
Health indicator kit for server-side monitoring and balancing. Inspired by Part V. Spring Boot Actuator: Production-ready feature 47.6.2 Writing custom HealthIndicators
npm i @qiwi/health-indicator
yarn add @qiwi/health-indicator
import express from 'express'
import {SemaphoreIndicator, Endpoint} from '@qiwi/health-indicator'
const app = express()
const indicator = new SemaphoreIndicator()
const endpoint = new Endpoint(indicator)
// Override 'getStatus' impl in accordance with your business logic
indicator.getStatus = () => {
...
return 'GREEN'
}
// ... or use separate class MyIndicator extends SemaphoreIndicator {...}
// ... or just directly set indicator status property
indicator.status = 'RED'
app.get('/health', endpoint.middleware)
Indicator composes aggregator logic, so its health status may be resolved from deps.
const dep1 = new SemaphoreIndicator({status: 'RED', critical: true})
const dep2 = new SemaphoreIndicator({status: 'GREEN'})
const dep3 = new SemaphoreIndicator({deps: {dep1, dep2}})
const indicator = new SemaphoreIndicator({deps: {dep3}})
indicator.health()
/*
{
status: 'RED',
critical: true,
deps: {
status: 'RED',
critical: true,
deps: {
dep1: {
status: 'RED',
critical: true
},
dep2: {
status: 'GREEN'
}
}
}
}
*/
The lib exports only a couple of indicator implementations:
StandardIndicator
(DOWN, OUT_OF_SERVICE, UNKNOWN, UP)SemaphoreIndicator
(RED, BROKEN, GREEN)To declare any CustomIndicator
you may easily extend the AbstractIndicator
import {AbstractIndicator} from '@qiwi/health-indicator'
const OK = 200
const SERVICE_UNAVAILABLE = 503
export const GREEN = 'GREEN'
export const RED = 'RED'
export const BROKEN = 'BROKEN'
export const STATUS_MAP = {GREEN, BROKEN, RED}
export const SEVERITY_ORDER = [RED, BROKEN, GREEN]
export const DEFAULT_HTTP_CODE = OK
export const HTTP_MAP = {[GREEN]: OK, [RED]: SERVICE_UNAVAILABLE, [BROKEN]: SERVICE_UNAVAILABLE}
export default class SemaphoreIndicator extends AbstractIndicator {
static getDefaultStatus (): string {
return BROKEN
}
static getDefaultHttpCode (): number {
return DEFAULT_HTTP_CODE
}
static getHttpMap (): Object {
return HTTP_MAP
}
static getStatusMap (): Object {
return STATUS_MAP
}
static getSeverityOrder (): string[] {
return SEVERITY_ORDER
}
}
FAQs
Health indicator kit for server-side monitoring & balancing
The npm package @qiwi/health-indicator receives a total of 33 weekly downloads. As such, @qiwi/health-indicator popularity was classified as not popular.
We found that @qiwi/health-indicator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.