@visulima/health-check 3.0.3 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/checks/dns-check.d.ts +11 -0
- package/dist/checks/http-check.d.ts +12 -0
- package/dist/checks/node-environment-check.d.ts +7 -0
- package/dist/checks/ping-check.d.ts +7 -0
- package/dist/handler/healthcheck.d.ts +12 -0
- package/dist/handler/readyhandler.d.ts +4 -0
- package/dist/healthcheck.d.ts +26 -0
- package/dist/index.d.ts +8 -61
- package/dist/types.d.ts +30 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## @visulima/health-check [3.0.4](https://github.com/visulima/visulima/compare/@visulima/health-check@3.0.3...@visulima/health-check@3.0.4) (2025-11-12)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* update package configurations and TypeScript definitions ([b59aa59](https://github.com/visulima/visulima/commit/b59aa59dac1508216b944f4b917fb4a7ab1f70a4))
|
|
6
|
+
|
|
7
|
+
### Miscellaneous Chores
|
|
8
|
+
|
|
9
|
+
* Add jsr file to all packages for release ([#565](https://github.com/visulima/visulima/issues/565)) ([ec91652](https://github.com/visulima/visulima/commit/ec91652b4e4112adf14ba152c1239a7703ba425a))
|
|
10
|
+
|
|
1
11
|
## @visulima/health-check [3.0.3](https://github.com/visulima/visulima/compare/@visulima/health-check@3.0.2...@visulima/health-check@3.0.3) (2025-11-07)
|
|
2
12
|
|
|
3
13
|
### Bug Fixes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Options } from "cacheable-lookup";
|
|
2
|
+
import type { Checker } from "../types.d.ts";
|
|
3
|
+
interface DnsOptions extends Options {
|
|
4
|
+
family?: "all" | 4 | 6;
|
|
5
|
+
hints?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Register the `dns` checker to ensure that a domain is reachable.
|
|
9
|
+
*/
|
|
10
|
+
declare const dnsCheck: (host: string, expectedAddresses?: string[], options?: DnsOptions) => Checker;
|
|
11
|
+
export default dnsCheck;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Checker } from "../types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Register the `http` checker to ensure http body and status is correct.
|
|
4
|
+
*/
|
|
5
|
+
declare const httpCheck: (host: RequestInfo | URL, options?: {
|
|
6
|
+
expected?: {
|
|
7
|
+
body?: string;
|
|
8
|
+
status?: number;
|
|
9
|
+
};
|
|
10
|
+
fetchOptions?: RequestInit;
|
|
11
|
+
}) => Checker;
|
|
12
|
+
export default httpCheck;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Checker } from "../types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Register the `env` checker to ensure that `NODE_ENV` environment
|
|
4
|
+
* variable is defined.
|
|
5
|
+
*/
|
|
6
|
+
declare const nodeEnvironmentCheck: (expectedEnvironment?: string) => Checker;
|
|
7
|
+
export default nodeEnvironmentCheck;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { extendedPingOptions } from "pingman";
|
|
2
|
+
import type { Checker } from "../types.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Register the `ping` checker to ensure that a domain is reachable.
|
|
5
|
+
*/
|
|
6
|
+
declare const pingCheck: (host: string, options?: extendedPingOptions) => Checker;
|
|
7
|
+
export default pingCheck;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import type { HealthCheck, HealthReport } from "../types.d.ts";
|
|
3
|
+
export interface HealthCheckApiPayload {
|
|
4
|
+
appName: string;
|
|
5
|
+
appVersion: string;
|
|
6
|
+
message: string;
|
|
7
|
+
reports: HealthReport;
|
|
8
|
+
status: "error" | "ok";
|
|
9
|
+
timestamp: string;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: (healthCheck: HealthCheck, sendHeader?: boolean | undefined) => <Request extends IncomingMessage, Response extends ServerResponse>(_: Request, response: Response) => Promise<void>;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import type { HealthCheck } from "../types.d.ts";
|
|
3
|
+
declare const _default: <Request extends IncomingMessage, Response extends ServerResponse>(healthCheck: HealthCheck) => (_request: Request, response: Response) => Promise<void>;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Checker, HealthCheck as HealthcheckInterface, HealthReport } from "./types.d.ts";
|
|
2
|
+
declare class Healthcheck implements HealthcheckInterface {
|
|
3
|
+
/**
|
|
4
|
+
* A copy of registered checkers
|
|
5
|
+
*/
|
|
6
|
+
private healthCheckers;
|
|
7
|
+
addChecker(service: string, checker: Checker): void;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the health check reports. The health checks are performed when
|
|
10
|
+
* this method is invoked.
|
|
11
|
+
*/
|
|
12
|
+
getReport(): Promise<{
|
|
13
|
+
healthy: boolean;
|
|
14
|
+
report: HealthReport;
|
|
15
|
+
}>;
|
|
16
|
+
isLive(): Promise<boolean>;
|
|
17
|
+
/**
|
|
18
|
+
* Returns an array of registered services names
|
|
19
|
+
*/
|
|
20
|
+
get servicesList(): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Invokes a given checker to collect the report metrics.
|
|
23
|
+
*/
|
|
24
|
+
private invokeChecker;
|
|
25
|
+
}
|
|
26
|
+
export default Healthcheck;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,61 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
message?: string;
|
|
10
|
-
timestamp: string;
|
|
11
|
-
};
|
|
12
|
-
meta?: any;
|
|
13
|
-
}
|
|
14
|
-
type Checker = () => Promise<HealthReportEntry>;
|
|
15
|
-
type HealthReport = Record<string, HealthReportEntry>;
|
|
16
|
-
interface HealthCheck {
|
|
17
|
-
addChecker: (service: string, checker: Checker) => void;
|
|
18
|
-
getReport: () => Promise<{
|
|
19
|
-
healthy: boolean;
|
|
20
|
-
report: HealthReport;
|
|
21
|
-
}>;
|
|
22
|
-
isLive: () => Promise<boolean>;
|
|
23
|
-
servicesList: string[];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface DnsOptions extends Options {
|
|
27
|
-
family?: "all" | 4 | 6;
|
|
28
|
-
hints?: number;
|
|
29
|
-
}
|
|
30
|
-
declare const dnsCheck: (host: string, expectedAddresses?: string[], options?: DnsOptions) => Checker;
|
|
31
|
-
|
|
32
|
-
declare const httpCheck: (host: RequestInfo | URL, options?: {
|
|
33
|
-
expected?: {
|
|
34
|
-
body?: string;
|
|
35
|
-
status?: number;
|
|
36
|
-
};
|
|
37
|
-
fetchOptions?: RequestInit;
|
|
38
|
-
}) => Checker;
|
|
39
|
-
|
|
40
|
-
declare const nodeEnvironmentCheck: (expectedEnvironment?: string) => Checker;
|
|
41
|
-
|
|
42
|
-
declare const pingCheck: (host: string, options?: extendedPingOptions) => Checker;
|
|
43
|
-
|
|
44
|
-
declare const _default$1: (healthCheck: HealthCheck, sendHeader?: boolean | undefined) => <Request extends IncomingMessage, Response extends ServerResponse>(_: Request, response: Response) => Promise<void>;
|
|
45
|
-
|
|
46
|
-
declare const _default: <Request extends IncomingMessage, Response extends ServerResponse>(healthCheck: HealthCheck) => (_request: Request, response: Response) => Promise<void>;
|
|
47
|
-
|
|
48
|
-
declare class Healthcheck implements HealthCheck {
|
|
49
|
-
private healthCheckers;
|
|
50
|
-
addChecker(service: string, checker: Checker): void;
|
|
51
|
-
getReport(): Promise<{
|
|
52
|
-
healthy: boolean;
|
|
53
|
-
report: HealthReport;
|
|
54
|
-
}>;
|
|
55
|
-
isLive(): Promise<boolean>;
|
|
56
|
-
get servicesList(): string[];
|
|
57
|
-
private invokeChecker;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { Healthcheck as HealthCheck, dnsCheck, _default$1 as healthCheckHandler, _default as healthReadyHandler, httpCheck, nodeEnvironmentCheck as nodeEnvCheck, pingCheck };
|
|
61
|
-
export type { Checker };
|
|
1
|
+
export { default as dnsCheck } from "./checks/dns-check.d.ts";
|
|
2
|
+
export { default as httpCheck } from "./checks/http-check.d.ts";
|
|
3
|
+
export { default as nodeEnvCheck } from "./checks/node-environment-check.d.ts";
|
|
4
|
+
export { default as pingCheck } from "./checks/ping-check.d.ts";
|
|
5
|
+
export { default as healthCheckHandler } from "./handler/healthcheck.d.ts";
|
|
6
|
+
export { default as healthReadyHandler } from "./handler/readyhandler.d.ts";
|
|
7
|
+
export { default as HealthCheck } from "./healthcheck.d.ts";
|
|
8
|
+
export type { Checker } from "./types.d.ts";
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape of health report entry. Each checker must
|
|
3
|
+
* return an object with similar shape.
|
|
4
|
+
*/
|
|
5
|
+
export interface HealthReportEntry {
|
|
6
|
+
displayName: string;
|
|
7
|
+
health: {
|
|
8
|
+
healthy: boolean;
|
|
9
|
+
message?: string;
|
|
10
|
+
timestamp: string;
|
|
11
|
+
};
|
|
12
|
+
meta?: any;
|
|
13
|
+
}
|
|
14
|
+
export type Checker = () => Promise<HealthReportEntry>;
|
|
15
|
+
/**
|
|
16
|
+
* The shape of entire report
|
|
17
|
+
*/
|
|
18
|
+
export type HealthReport = Record<string, HealthReportEntry>;
|
|
19
|
+
/**
|
|
20
|
+
* Shape of health check contract
|
|
21
|
+
*/
|
|
22
|
+
export interface HealthCheck {
|
|
23
|
+
addChecker: (service: string, checker: Checker) => void;
|
|
24
|
+
getReport: () => Promise<{
|
|
25
|
+
healthy: boolean;
|
|
26
|
+
report: HealthReport;
|
|
27
|
+
}>;
|
|
28
|
+
isLive: () => Promise<boolean>;
|
|
29
|
+
servicesList: string[];
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/health-check",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"description": "A library built to provide support for defining service health for node services. It allows you to register async health checks for your dependencies and the service itself, provides a health endpoint that exposes their status, and health metrics.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|