@visulima/health-check 2.0.17 → 2.0.19

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/LICENSE.md +27 -0
  3. package/README.md +8 -8
  4. package/dist/index.cjs +21 -1
  5. package/dist/index.d.cts +2 -2
  6. package/dist/index.d.mts +2 -2
  7. package/dist/index.d.ts +2 -2
  8. package/dist/index.mjs +7 -1
  9. package/dist/packem_shared/HealthCheck-B5xOyzcA.cjs +57 -0
  10. package/dist/packem_shared/HealthCheck-nWvpT85r.mjs +55 -0
  11. package/dist/packem_shared/dnsCheck-CKpwi39o.cjs +64 -0
  12. package/dist/packem_shared/dnsCheck-DJXOtLo2.mjs +58 -0
  13. package/dist/packem_shared/healthCheckHandler-BIIllStf.cjs +24 -0
  14. package/dist/packem_shared/healthCheckHandler-C0NYbHG_.mjs +22 -0
  15. package/dist/packem_shared/healthReadyHandler-Bd4123kn.mjs +11 -0
  16. package/dist/packem_shared/healthReadyHandler-vdf1928k.cjs +13 -0
  17. package/dist/packem_shared/httpCheck-CmLmorh2.cjs +53 -0
  18. package/dist/packem_shared/httpCheck-ivA5vEeE.mjs +51 -0
  19. package/dist/packem_shared/nodeEnvCheck-C2C9wY2Q.cjs +36 -0
  20. package/dist/packem_shared/nodeEnvCheck-CYVfgkJ_.mjs +34 -0
  21. package/dist/packem_shared/pingCheck-CYOzCjjQ.cjs +49 -0
  22. package/dist/packem_shared/pingCheck-W2tp3p2k.mjs +43 -0
  23. package/package.json +27 -27
  24. package/dist/packem_shared/HealthCheck-CypoYHvz.mjs +0 -1
  25. package/dist/packem_shared/HealthCheck-DQvQhFYY.cjs +0 -1
  26. package/dist/packem_shared/dnsCheck-CN6R59pd.cjs +0 -1
  27. package/dist/packem_shared/dnsCheck-G72qe__U.mjs +0 -1
  28. package/dist/packem_shared/healthCheckHandler-BH0Fcvsh.cjs +0 -1
  29. package/dist/packem_shared/healthCheckHandler-BdYk897h.mjs +0 -1
  30. package/dist/packem_shared/healthReadyHandler-D_Z0BVtR.mjs +0 -1
  31. package/dist/packem_shared/healthReadyHandler-DjRXCune.cjs +0 -1
  32. package/dist/packem_shared/httpCheck-BNlBtiV7.mjs +0 -1
  33. package/dist/packem_shared/httpCheck-DT6HrAPG.cjs +0 -1
  34. package/dist/packem_shared/nodeEnvCheck-BxNJ8ArD.mjs +0 -1
  35. package/dist/packem_shared/nodeEnvCheck-aT51eSWt.cjs +0 -1
  36. package/dist/packem_shared/pingCheck-DIrh3Cwy.cjs +0 -1
  37. package/dist/packem_shared/pingCheck-DWJlRAgo.mjs +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ ## @visulima/health-check [2.0.19](https://github.com/visulima/visulima/compare/@visulima/health-check@2.0.18...@visulima/health-check@2.0.19) (2025-01-12)
2
+
3
+ ### Bug Fixes
4
+
5
+ * updated @visulima/packem, and all other dev dependencies ([7797a1c](https://github.com/visulima/visulima/commit/7797a1c3e6f1fc532895247bd88285a8a9883c40))
6
+
7
+ ### Miscellaneous Chores
8
+
9
+ * updated dev dependencies ([9de2eab](https://github.com/visulima/visulima/commit/9de2eab91e95c8b9289d12f863a5167218770650))
10
+
11
+ ## @visulima/health-check [2.0.18](https://github.com/visulima/visulima/compare/@visulima/health-check@2.0.17...@visulima/health-check@2.0.18) (2024-12-12)
12
+
13
+ ### Bug Fixes
14
+
15
+ * added missing placeholder variables into LICENSE.md file ([cef32c6](https://github.com/visulima/visulima/commit/cef32c6eb19dc3215a835e848ef12223a8fa05e0))
16
+ * allow node v23 ([8ca929a](https://github.com/visulima/visulima/commit/8ca929af311ce8036cbbfde68b6db05381b860a5))
17
+ * allowed node 23, updated dev dependencies ([f99d34e](https://github.com/visulima/visulima/commit/f99d34e01f6b13be8586a1b5d37dc8b8df0a5817))
18
+ * updated packem to v1.8.2 ([23f869b](https://github.com/visulima/visulima/commit/23f869b4120856cc97e2bffa6d508e2ae30420ea))
19
+ * updated packem to v1.9.2 ([47bdc2d](https://github.com/visulima/visulima/commit/47bdc2dfaeca4e7014dbe7772eae2fdf8c8b35bb))
20
+
21
+ ### Styles
22
+
23
+ * cs fixes ([46d31e0](https://github.com/visulima/visulima/commit/46d31e082e1865262bf380859c14fabd28ff456d))
24
+
25
+ ### Miscellaneous Chores
26
+
27
+ * updated dev dependencies ([a916944](https://github.com/visulima/visulima/commit/a916944b888bb34c34b0c54328b38d29e4399857))
28
+
1
29
  ## @visulima/health-check [2.0.17](https://github.com/visulima/visulima/compare/@visulima/health-check@2.0.16...@visulima/health-check@2.0.17) (2024-10-05)
2
30
 
3
31
  ### Bug Fixes
package/LICENSE.md CHANGED
@@ -0,0 +1,27 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 visulima
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ <!-- DEPENDENCIES -->
24
+ <!-- /DEPENDENCIES -->
25
+
26
+ <!-- TYPE_DEPENDENCIES -->
27
+ <!-- /TYPE_DEPENDENCIES -->
package/README.md CHANGED
@@ -43,9 +43,9 @@ pnpm add @visulima/health-check
43
43
 
44
44
  Keeping the API health check endpoints generic allows to use them for multiple purposes. In this section, we will review of the everyday use cases of an API health check endpoint
45
45
 
46
- - Container orchestrators and API load balancers can use API health check endpoint to find out about the process status
47
- - Usage of memory, disk, and other server resources can be monitored via API health check endpoints
48
- - Health checks can test APIs dependencies, such as databases and external service endpoints, to confirm availability and normal functioning.
46
+ - Container orchestrators and API load balancers can use API health check endpoint to find out about the process status
47
+ - Usage of memory, disk, and other server resources can be monitored via API health check endpoints
48
+ - Health checks can test APIs dependencies, such as databases and external service endpoints, to confirm availability and normal functioning.
49
49
 
50
50
  ## Usage
51
51
 
@@ -63,11 +63,11 @@ export default healthCheckHandler(HealthCheckService); // returns a http handler
63
63
 
64
64
  There are at least three different types of API health check endpoints designed to serve specific purposes.
65
65
 
66
- - _The readiness endpoint_, often available via `/health/ready`, returns the readiness state to accept incoming requests from the gateway or the upstream proxy. Readiness signals that the app is running normally but isn’t ready to receive requests yet.
66
+ - _The readiness endpoint_, often available via `/health/ready`, returns the readiness state to accept incoming requests from the gateway or the upstream proxy. Readiness signals that the app is running normally but isn’t ready to receive requests yet.
67
67
 
68
- - _The liveness endpoint_, often available via `/health/live`, returns the liveness of a microservice. If the check does not return the expected response, it means that the process is unhealthy or dead and should be replaced as soon as possible.
68
+ - _The liveness endpoint_, often available via `/health/live`, returns the liveness of a microservice. If the check does not return the expected response, it means that the process is unhealthy or dead and should be replaced as soon as possible.
69
69
 
70
- - _The generic health check endpoint_, often available via `/health`, returns the status of the service and the dependencies.
70
+ - _The generic health check endpoint_, often available via `/health`, returns the status of the service and the dependencies.
71
71
 
72
72
  Consider the following example: an API that loads JSON-based data into memory to serve requests.
73
73
 
@@ -189,8 +189,8 @@ If you would like to help take a look at the [list of issues](https://github.com
189
189
 
190
190
  ## Credits
191
191
 
192
- - [Daniel Bannert](https://github.com/prisis)
193
- - [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
192
+ - [Daniel Bannert](https://github.com/prisis)
193
+ - [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
194
194
 
195
195
  ## License
196
196
 
package/dist/index.cjs CHANGED
@@ -1 +1,21 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./packem_shared/dnsCheck-CN6R59pd.cjs"),h=require("./packem_shared/httpCheck-DT6HrAPG.cjs"),t=require("./packem_shared/nodeEnvCheck-aT51eSWt.cjs"),r=require("./packem_shared/pingCheck-DIrh3Cwy.cjs"),c=require("./packem_shared/healthCheckHandler-BH0Fcvsh.cjs"),n=require("./packem_shared/healthReadyHandler-DjRXCune.cjs"),a=require("./packem_shared/HealthCheck-DQvQhFYY.cjs");exports.dnsCheck=e;exports.httpCheck=h;exports.nodeEnvCheck=t;exports.pingCheck=r;exports.healthCheckHandler=c;exports.healthReadyHandler=n;exports.HealthCheck=a;
1
+ 'use strict';
2
+
3
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
+
5
+ const dnsCheck = require('./packem_shared/dnsCheck-CKpwi39o.cjs');
6
+ const httpCheck = require('./packem_shared/httpCheck-CmLmorh2.cjs');
7
+ const nodeEnvCheck = require('./packem_shared/nodeEnvCheck-C2C9wY2Q.cjs');
8
+ const pingCheck = require('./packem_shared/pingCheck-CYOzCjjQ.cjs');
9
+ const healthCheckHandler = require('./packem_shared/healthCheckHandler-BIIllStf.cjs');
10
+ const healthReadyHandler = require('./packem_shared/healthReadyHandler-vdf1928k.cjs');
11
+ const HealthCheck = require('./packem_shared/HealthCheck-B5xOyzcA.cjs');
12
+
13
+
14
+
15
+ exports.dnsCheck = dnsCheck;
16
+ exports.httpCheck = httpCheck;
17
+ exports.nodeEnvCheck = nodeEnvCheck;
18
+ exports.pingCheck = pingCheck;
19
+ exports.healthCheckHandler = healthCheckHandler;
20
+ exports.healthReadyHandler = healthReadyHandler;
21
+ exports.HealthCheck = HealthCheck;
package/dist/index.d.cts CHANGED
@@ -41,9 +41,9 @@ declare const nodeEnvironmentCheck: (expectedEnvironment?: string) => Checker;
41
41
 
42
42
  declare const pingCheck: (host: string, options?: extendedPingOptions) => Checker;
43
43
 
44
- declare const _default$1: (healthCheck: HealthCheck, sendHeader?: boolean | undefined) => <Request extends IncomingMessage, Response extends ServerResponse<IncomingMessage>>(_: Request, response: Response) => Promise<void>;
44
+ declare const _default$1: (healthCheck: HealthCheck, sendHeader?: boolean | undefined) => <Request extends IncomingMessage, Response extends ServerResponse>(_: Request, response: Response) => Promise<void>;
45
45
 
46
- declare const _default: <Request extends IncomingMessage, Response extends ServerResponse<IncomingMessage>>(healthCheck: HealthCheck) => (_request: Request, response: Response) => Promise<void>;
46
+ declare const _default: <Request extends IncomingMessage, Response extends ServerResponse>(healthCheck: HealthCheck) => (_request: Request, response: Response) => Promise<void>;
47
47
 
48
48
  declare class Healthcheck implements HealthCheck {
49
49
  private healthCheckers;
package/dist/index.d.mts CHANGED
@@ -41,9 +41,9 @@ declare const nodeEnvironmentCheck: (expectedEnvironment?: string) => Checker;
41
41
 
42
42
  declare const pingCheck: (host: string, options?: extendedPingOptions) => Checker;
43
43
 
44
- declare const _default$1: (healthCheck: HealthCheck, sendHeader?: boolean | undefined) => <Request extends IncomingMessage, Response extends ServerResponse<IncomingMessage>>(_: Request, response: Response) => Promise<void>;
44
+ declare const _default$1: (healthCheck: HealthCheck, sendHeader?: boolean | undefined) => <Request extends IncomingMessage, Response extends ServerResponse>(_: Request, response: Response) => Promise<void>;
45
45
 
46
- declare const _default: <Request extends IncomingMessage, Response extends ServerResponse<IncomingMessage>>(healthCheck: HealthCheck) => (_request: Request, response: Response) => Promise<void>;
46
+ declare const _default: <Request extends IncomingMessage, Response extends ServerResponse>(healthCheck: HealthCheck) => (_request: Request, response: Response) => Promise<void>;
47
47
 
48
48
  declare class Healthcheck implements HealthCheck {
49
49
  private healthCheckers;
package/dist/index.d.ts CHANGED
@@ -41,9 +41,9 @@ declare const nodeEnvironmentCheck: (expectedEnvironment?: string) => Checker;
41
41
 
42
42
  declare const pingCheck: (host: string, options?: extendedPingOptions) => Checker;
43
43
 
44
- declare const _default$1: (healthCheck: HealthCheck, sendHeader?: boolean | undefined) => <Request extends IncomingMessage, Response extends ServerResponse<IncomingMessage>>(_: Request, response: Response) => Promise<void>;
44
+ declare const _default$1: (healthCheck: HealthCheck, sendHeader?: boolean | undefined) => <Request extends IncomingMessage, Response extends ServerResponse>(_: Request, response: Response) => Promise<void>;
45
45
 
46
- declare const _default: <Request extends IncomingMessage, Response extends ServerResponse<IncomingMessage>>(healthCheck: HealthCheck) => (_request: Request, response: Response) => Promise<void>;
46
+ declare const _default: <Request extends IncomingMessage, Response extends ServerResponse>(healthCheck: HealthCheck) => (_request: Request, response: Response) => Promise<void>;
47
47
 
48
48
  declare class Healthcheck implements HealthCheck {
49
49
  private healthCheckers;
package/dist/index.mjs CHANGED
@@ -1 +1,7 @@
1
- import{default as t}from"./packem_shared/dnsCheck-G72qe__U.mjs";import{default as o}from"./packem_shared/httpCheck-BNlBtiV7.mjs";import{default as d}from"./packem_shared/nodeEnvCheck-BxNJ8ArD.mjs";import{default as l}from"./packem_shared/pingCheck-DWJlRAgo.mjs";import{default as s}from"./packem_shared/healthCheckHandler-BdYk897h.mjs";import{default as u}from"./packem_shared/healthReadyHandler-D_Z0BVtR.mjs";import{default as c}from"./packem_shared/HealthCheck-CypoYHvz.mjs";export{c as HealthCheck,t as dnsCheck,s as healthCheckHandler,u as healthReadyHandler,o as httpCheck,d as nodeEnvCheck,l as pingCheck};
1
+ export { default as dnsCheck } from './packem_shared/dnsCheck-DJXOtLo2.mjs';
2
+ export { default as httpCheck } from './packem_shared/httpCheck-ivA5vEeE.mjs';
3
+ export { default as nodeEnvCheck } from './packem_shared/nodeEnvCheck-CYVfgkJ_.mjs';
4
+ export { default as pingCheck } from './packem_shared/pingCheck-W2tp3p2k.mjs';
5
+ export { default as healthCheckHandler } from './packem_shared/healthCheckHandler-C0NYbHG_.mjs';
6
+ export { default as healthReadyHandler } from './packem_shared/healthReadyHandler-Bd4123kn.mjs';
7
+ export { default as HealthCheck } from './packem_shared/HealthCheck-nWvpT85r.mjs';
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ class Healthcheck {
6
+ static {
7
+ __name(this, "Healthcheck");
8
+ }
9
+ /**
10
+ * A copy of registered checkers
11
+ */
12
+ healthCheckers = {};
13
+ addChecker(service, checker) {
14
+ this.healthCheckers[service] = checker;
15
+ }
16
+ /**
17
+ * Returns the health check reports. The health checks are performed when
18
+ * this method is invoked.
19
+ */
20
+ async getReport() {
21
+ const report = {};
22
+ await Promise.all(Object.keys(this.healthCheckers).map(async (service) => await this.invokeChecker(service, report)));
23
+ const unhealthyService = Object.keys(report).find((service) => !report[service].health.healthy);
24
+ return { healthy: !unhealthyService, report };
25
+ }
26
+ async isLive() {
27
+ const { healthy } = await this.getReport();
28
+ return healthy;
29
+ }
30
+ /**
31
+ * Returns an array of registered services names
32
+ */
33
+ get servicesList() {
34
+ return Object.keys(this.healthCheckers);
35
+ }
36
+ /**
37
+ * Invokes a given checker to collect the report metrics.
38
+ */
39
+ async invokeChecker(service, reportSheet) {
40
+ const checker = this.healthCheckers[service];
41
+ let report;
42
+ try {
43
+ report = await checker();
44
+ report.displayName = report.displayName || service;
45
+ } catch (error) {
46
+ report = {
47
+ displayName: service,
48
+ health: { healthy: false, message: error.message, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
49
+ meta: { fatal: true }
50
+ };
51
+ }
52
+ reportSheet[service] = report;
53
+ return report.health.healthy;
54
+ }
55
+ }
56
+
57
+ module.exports = Healthcheck;
@@ -0,0 +1,55 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ class Healthcheck {
4
+ static {
5
+ __name(this, "Healthcheck");
6
+ }
7
+ /**
8
+ * A copy of registered checkers
9
+ */
10
+ healthCheckers = {};
11
+ addChecker(service, checker) {
12
+ this.healthCheckers[service] = checker;
13
+ }
14
+ /**
15
+ * Returns the health check reports. The health checks are performed when
16
+ * this method is invoked.
17
+ */
18
+ async getReport() {
19
+ const report = {};
20
+ await Promise.all(Object.keys(this.healthCheckers).map(async (service) => await this.invokeChecker(service, report)));
21
+ const unhealthyService = Object.keys(report).find((service) => !report[service].health.healthy);
22
+ return { healthy: !unhealthyService, report };
23
+ }
24
+ async isLive() {
25
+ const { healthy } = await this.getReport();
26
+ return healthy;
27
+ }
28
+ /**
29
+ * Returns an array of registered services names
30
+ */
31
+ get servicesList() {
32
+ return Object.keys(this.healthCheckers);
33
+ }
34
+ /**
35
+ * Invokes a given checker to collect the report metrics.
36
+ */
37
+ async invokeChecker(service, reportSheet) {
38
+ const checker = this.healthCheckers[service];
39
+ let report;
40
+ try {
41
+ report = await checker();
42
+ report.displayName = report.displayName || service;
43
+ } catch (error) {
44
+ report = {
45
+ displayName: service,
46
+ health: { healthy: false, message: error.message, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
47
+ meta: { fatal: true }
48
+ };
49
+ }
50
+ reportSheet[service] = report;
51
+ return report.health.healthy;
52
+ }
53
+ }
54
+
55
+ export { Healthcheck as default };
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ const CacheableLookup = require('cacheable-lookup');
4
+
5
+ const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e ? e.default : e;
6
+
7
+ const CacheableLookup__default = /*#__PURE__*/_interopDefaultCompat(CacheableLookup);
8
+
9
+ var __defProp = Object.defineProperty;
10
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
+ const DISPLAY_NAME = "DNS check for";
12
+ const dnsCheck = /* @__PURE__ */ __name((host, expectedAddresses, options) => async () => {
13
+ const { family = "all", hints, ...config } = options ?? {};
14
+ const cacheable = new CacheableLookup__default(config);
15
+ try {
16
+ const meta = await cacheable.lookupAsync(host.replace(/^https?:\/\//, ""), {
17
+ hints,
18
+ ...family === "all" ? { all: true } : { family }
19
+ });
20
+ if (Array.isArray(expectedAddresses) && !expectedAddresses.includes(meta.address)) {
21
+ return {
22
+ displayName: `${DISPLAY_NAME} ${host}`,
23
+ health: {
24
+ healthy: false,
25
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
26
+ message: `${DISPLAY_NAME} ${host} returned address ${meta.address} instead of ${expectedAddresses.join(", ")}.`,
27
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
28
+ },
29
+ meta: {
30
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
31
+ addresses: meta,
32
+ host
33
+ }
34
+ };
35
+ }
36
+ return {
37
+ displayName: `${DISPLAY_NAME} ${host}`,
38
+ health: {
39
+ healthy: true,
40
+ message: `${DISPLAY_NAME} ${host} were resolved.`,
41
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
42
+ },
43
+ meta: {
44
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
45
+ addresses: meta,
46
+ host
47
+ }
48
+ };
49
+ } catch (error) {
50
+ return {
51
+ displayName: `${DISPLAY_NAME} ${host}`,
52
+ health: {
53
+ healthy: false,
54
+ message: error.message,
55
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
56
+ },
57
+ meta: {
58
+ host
59
+ }
60
+ };
61
+ }
62
+ }, "dnsCheck");
63
+
64
+ module.exports = dnsCheck;
@@ -0,0 +1,58 @@
1
+ import CacheableLookup from 'cacheable-lookup';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const DISPLAY_NAME = "DNS check for";
6
+ const dnsCheck = /* @__PURE__ */ __name((host, expectedAddresses, options) => async () => {
7
+ const { family = "all", hints, ...config } = options ?? {};
8
+ const cacheable = new CacheableLookup(config);
9
+ try {
10
+ const meta = await cacheable.lookupAsync(host.replace(/^https?:\/\//, ""), {
11
+ hints,
12
+ ...family === "all" ? { all: true } : { family }
13
+ });
14
+ if (Array.isArray(expectedAddresses) && !expectedAddresses.includes(meta.address)) {
15
+ return {
16
+ displayName: `${DISPLAY_NAME} ${host}`,
17
+ health: {
18
+ healthy: false,
19
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
20
+ message: `${DISPLAY_NAME} ${host} returned address ${meta.address} instead of ${expectedAddresses.join(", ")}.`,
21
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
22
+ },
23
+ meta: {
24
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
25
+ addresses: meta,
26
+ host
27
+ }
28
+ };
29
+ }
30
+ return {
31
+ displayName: `${DISPLAY_NAME} ${host}`,
32
+ health: {
33
+ healthy: true,
34
+ message: `${DISPLAY_NAME} ${host} were resolved.`,
35
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
36
+ },
37
+ meta: {
38
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
39
+ addresses: meta,
40
+ host
41
+ }
42
+ };
43
+ } catch (error) {
44
+ return {
45
+ displayName: `${DISPLAY_NAME} ${host}`,
46
+ health: {
47
+ healthy: false,
48
+ message: error.message,
49
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
50
+ },
51
+ meta: {
52
+ host
53
+ }
54
+ };
55
+ }
56
+ }, "dnsCheck");
57
+
58
+ export { dnsCheck as default };
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ const httpStatusCodes = require('http-status-codes');
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ const healthcheck = /* @__PURE__ */ __name((healthCheck, sendHeader = true) => async (_, response) => {
8
+ const { healthy, report } = await healthCheck.getReport();
9
+ const payload = {
10
+ appName: process.env.APP_NAME ?? "unknown",
11
+ appVersion: process.env.APP_VERSION ?? "unknown",
12
+ message: healthy ? "Health check successful" : "Health check failed",
13
+ reports: report,
14
+ status: healthy ? "ok" : "error",
15
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
16
+ };
17
+ response.statusCode = healthy ? httpStatusCodes.StatusCodes.OK : httpStatusCodes.StatusCodes.SERVICE_UNAVAILABLE;
18
+ if (sendHeader) {
19
+ response.setHeader("Content-Type", "application/json");
20
+ }
21
+ response.end(JSON.stringify(payload, null, 2));
22
+ }, "default");
23
+
24
+ module.exports = healthcheck;
@@ -0,0 +1,22 @@
1
+ import { StatusCodes } from 'http-status-codes';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const healthcheck = /* @__PURE__ */ __name((healthCheck, sendHeader = true) => async (_, response) => {
6
+ const { healthy, report } = await healthCheck.getReport();
7
+ const payload = {
8
+ appName: process.env.APP_NAME ?? "unknown",
9
+ appVersion: process.env.APP_VERSION ?? "unknown",
10
+ message: healthy ? "Health check successful" : "Health check failed",
11
+ reports: report,
12
+ status: healthy ? "ok" : "error",
13
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
14
+ };
15
+ response.statusCode = healthy ? StatusCodes.OK : StatusCodes.SERVICE_UNAVAILABLE;
16
+ if (sendHeader) {
17
+ response.setHeader("Content-Type", "application/json");
18
+ }
19
+ response.end(JSON.stringify(payload, null, 2));
20
+ }, "default");
21
+
22
+ export { healthcheck as default };
@@ -0,0 +1,11 @@
1
+ import { StatusCodes } from 'http-status-codes';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const readyhandler = /* @__PURE__ */ __name((healthCheck) => async (_request, response) => {
6
+ const { healthy } = await healthCheck.getReport();
7
+ response.statusCode = healthy ? StatusCodes.NO_CONTENT : StatusCodes.SERVICE_UNAVAILABLE;
8
+ response.end();
9
+ }, "default");
10
+
11
+ export { readyhandler as default };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ const httpStatusCodes = require('http-status-codes');
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ const readyhandler = /* @__PURE__ */ __name((healthCheck) => async (_request, response) => {
8
+ const { healthy } = await healthCheck.getReport();
9
+ response.statusCode = healthy ? httpStatusCodes.StatusCodes.NO_CONTENT : httpStatusCodes.StatusCodes.SERVICE_UNAVAILABLE;
10
+ response.end();
11
+ }, "default");
12
+
13
+ module.exports = readyhandler;
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ const node_assert = require('node:assert');
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ const DISPLAY_NAME = "HTTP check for";
8
+ const httpCheck = /* @__PURE__ */ __name((host, options) => async () => {
9
+ try {
10
+ const response = await fetch(host, options?.fetchOptions ?? {});
11
+ if (options?.expected?.status !== undefined && options.expected.status !== response.status) {
12
+ throw new Error(`${DISPLAY_NAME} ${host} returned status ${response.status} instead of ${options.expected.status}`);
13
+ }
14
+ if (options?.expected?.body !== undefined) {
15
+ const textBody = await response.text();
16
+ try {
17
+ node_assert.deepStrictEqual(textBody, options.expected.body);
18
+ } catch {
19
+ throw new Error(
20
+ `${DISPLAY_NAME} ${host} returned body ${JSON.stringify(textBody)} instead of ${JSON.stringify(options.expected.body)}`
21
+ );
22
+ }
23
+ }
24
+ return {
25
+ displayName: `${DISPLAY_NAME} ${host}`,
26
+ health: {
27
+ healthy: true,
28
+ message: `${DISPLAY_NAME} ${host} was successful.`,
29
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
30
+ },
31
+ meta: {
32
+ host,
33
+ method: options?.fetchOptions?.method ?? "GET",
34
+ status: response.status
35
+ }
36
+ };
37
+ } catch (error) {
38
+ return {
39
+ displayName: `${DISPLAY_NAME} ${host}`,
40
+ health: {
41
+ healthy: false,
42
+ message: error.message,
43
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
44
+ },
45
+ meta: {
46
+ host,
47
+ method: options?.fetchOptions?.method ?? "GET"
48
+ }
49
+ };
50
+ }
51
+ }, "httpCheck");
52
+
53
+ module.exports = httpCheck;
@@ -0,0 +1,51 @@
1
+ import { deepStrictEqual } from 'node:assert';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const DISPLAY_NAME = "HTTP check for";
6
+ const httpCheck = /* @__PURE__ */ __name((host, options) => async () => {
7
+ try {
8
+ const response = await fetch(host, options?.fetchOptions ?? {});
9
+ if (options?.expected?.status !== undefined && options.expected.status !== response.status) {
10
+ throw new Error(`${DISPLAY_NAME} ${host} returned status ${response.status} instead of ${options.expected.status}`);
11
+ }
12
+ if (options?.expected?.body !== undefined) {
13
+ const textBody = await response.text();
14
+ try {
15
+ deepStrictEqual(textBody, options.expected.body);
16
+ } catch {
17
+ throw new Error(
18
+ `${DISPLAY_NAME} ${host} returned body ${JSON.stringify(textBody)} instead of ${JSON.stringify(options.expected.body)}`
19
+ );
20
+ }
21
+ }
22
+ return {
23
+ displayName: `${DISPLAY_NAME} ${host}`,
24
+ health: {
25
+ healthy: true,
26
+ message: `${DISPLAY_NAME} ${host} was successful.`,
27
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
28
+ },
29
+ meta: {
30
+ host,
31
+ method: options?.fetchOptions?.method ?? "GET",
32
+ status: response.status
33
+ }
34
+ };
35
+ } catch (error) {
36
+ return {
37
+ displayName: `${DISPLAY_NAME} ${host}`,
38
+ health: {
39
+ healthy: false,
40
+ message: error.message,
41
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
42
+ },
43
+ meta: {
44
+ host,
45
+ method: options?.fetchOptions?.method ?? "GET"
46
+ }
47
+ };
48
+ }
49
+ }, "httpCheck");
50
+
51
+ export { httpCheck as default };
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const DISPLAY_NAME = "Node Environment Check";
6
+ const nodeEnvironmentCheck = /* @__PURE__ */ __name((expectedEnvironment) => async () => {
7
+ const environment = process.env.NODE_ENV;
8
+ let errorMessage;
9
+ if (environment !== undefined && expectedEnvironment !== undefined && environment !== expectedEnvironment) {
10
+ errorMessage = `NODE_ENV environment variable is set to "${environment}" instead of "${expectedEnvironment}".`;
11
+ } else if (!environment) {
12
+ errorMessage = ["Missing NODE_ENV environment variable.", "It can make some parts of the application misbehave"].join(" ");
13
+ }
14
+ if (errorMessage !== undefined) {
15
+ return {
16
+ displayName: DISPLAY_NAME,
17
+ health: {
18
+ healthy: false,
19
+ message: errorMessage,
20
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
21
+ }
22
+ };
23
+ }
24
+ return {
25
+ displayName: DISPLAY_NAME,
26
+ health: {
27
+ healthy: true,
28
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
29
+ },
30
+ meta: {
31
+ env: environment
32
+ }
33
+ };
34
+ }, "nodeEnvironmentCheck");
35
+
36
+ module.exports = nodeEnvironmentCheck;
@@ -0,0 +1,34 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ const DISPLAY_NAME = "Node Environment Check";
4
+ const nodeEnvironmentCheck = /* @__PURE__ */ __name((expectedEnvironment) => async () => {
5
+ const environment = process.env.NODE_ENV;
6
+ let errorMessage;
7
+ if (environment !== undefined && expectedEnvironment !== undefined && environment !== expectedEnvironment) {
8
+ errorMessage = `NODE_ENV environment variable is set to "${environment}" instead of "${expectedEnvironment}".`;
9
+ } else if (!environment) {
10
+ errorMessage = ["Missing NODE_ENV environment variable.", "It can make some parts of the application misbehave"].join(" ");
11
+ }
12
+ if (errorMessage !== undefined) {
13
+ return {
14
+ displayName: DISPLAY_NAME,
15
+ health: {
16
+ healthy: false,
17
+ message: errorMessage,
18
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
19
+ }
20
+ };
21
+ }
22
+ return {
23
+ displayName: DISPLAY_NAME,
24
+ health: {
25
+ healthy: true,
26
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
27
+ },
28
+ meta: {
29
+ env: environment
30
+ }
31
+ };
32
+ }, "nodeEnvironmentCheck");
33
+
34
+ export { nodeEnvironmentCheck as default };
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ const ping = require('pingman');
4
+
5
+ const _interopDefaultCompat = e => e && typeof e === 'object' && 'default' in e ? e.default : e;
6
+
7
+ const ping__default = /*#__PURE__*/_interopDefaultCompat(ping);
8
+
9
+ var __defProp = Object.defineProperty;
10
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
11
+ const DISPLAY_NAME = "Ping check for";
12
+ const pingCheck = /* @__PURE__ */ __name((host, options) => async () => {
13
+ try {
14
+ const response = await ping__default(host.replace(/^https?:\/\//, ""), options);
15
+ if (!response.alive) {
16
+ return {
17
+ displayName: `${DISPLAY_NAME} ${host}`,
18
+ health: {
19
+ healthy: false,
20
+ message: `Ping failed for ${host}.`,
21
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
22
+ },
23
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
24
+ meta: response
25
+ };
26
+ }
27
+ return {
28
+ displayName: `${DISPLAY_NAME} ${host}`,
29
+ health: {
30
+ healthy: true,
31
+ message: `${DISPLAY_NAME} ${host} was successful.`,
32
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
33
+ },
34
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
35
+ meta: response
36
+ };
37
+ } catch (error) {
38
+ return {
39
+ displayName: `${DISPLAY_NAME} ${host}`,
40
+ health: {
41
+ healthy: false,
42
+ message: error.message,
43
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
44
+ }
45
+ };
46
+ }
47
+ }, "pingCheck");
48
+
49
+ module.exports = pingCheck;
@@ -0,0 +1,43 @@
1
+ import ping from 'pingman';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ const DISPLAY_NAME = "Ping check for";
6
+ const pingCheck = /* @__PURE__ */ __name((host, options) => async () => {
7
+ try {
8
+ const response = await ping(host.replace(/^https?:\/\//, ""), options);
9
+ if (!response.alive) {
10
+ return {
11
+ displayName: `${DISPLAY_NAME} ${host}`,
12
+ health: {
13
+ healthy: false,
14
+ message: `Ping failed for ${host}.`,
15
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
16
+ },
17
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18
+ meta: response
19
+ };
20
+ }
21
+ return {
22
+ displayName: `${DISPLAY_NAME} ${host}`,
23
+ health: {
24
+ healthy: true,
25
+ message: `${DISPLAY_NAME} ${host} was successful.`,
26
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
27
+ },
28
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
29
+ meta: response
30
+ };
31
+ } catch (error) {
32
+ return {
33
+ displayName: `${DISPLAY_NAME} ${host}`,
34
+ health: {
35
+ healthy: false,
36
+ message: error.message,
37
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
38
+ }
39
+ };
40
+ }
41
+ }, "pingCheck");
42
+
43
+ export { pingCheck as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/health-check",
3
- "version": "2.0.17",
3
+ "version": "2.0.19",
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",
@@ -75,50 +75,50 @@
75
75
  "devDependencies": {
76
76
  "@anolilab/eslint-config": "^15.0.3",
77
77
  "@anolilab/prettier-config": "^5.0.14",
78
- "@anolilab/semantic-release-pnpm": "^1.1.3",
79
- "@anolilab/semantic-release-preset": "^9.0.0",
80
- "@arethetypeswrong/cli": "^0.16.4",
81
- "@arthurgeron/eslint-plugin-react-usememo": "^2.4.1",
82
- "@babel/core": "^7.25.7",
78
+ "@anolilab/semantic-release-pnpm": "^1.1.6",
79
+ "@anolilab/semantic-release-preset": "^9.0.3",
80
+ "@arethetypeswrong/cli": "^0.17.2",
81
+ "@arthurgeron/eslint-plugin-react-usememo": "^2.4.4",
82
+ "@babel/core": "^7.26.0",
83
83
  "@rushstack/eslint-plugin-security": "^0.8.3",
84
- "@testing-library/react": "^16.0.1",
84
+ "@testing-library/react": "^16.1.0",
85
85
  "@types/node": "18.19.15",
86
- "@visulima/packem": "1.0.7",
87
- "@vitest/coverage-v8": "^2.1.2",
88
- "@vitest/ui": "^2.1.2",
86
+ "@visulima/packem": "1.10.7",
87
+ "@vitest/coverage-v8": "^2.1.8",
88
+ "@vitest/ui": "^2.1.8",
89
89
  "conventional-changelog-conventionalcommits": "8.0.0",
90
90
  "cross-env": "^7.0.3",
91
- "cross-fetch": "^4.0.0",
92
- "esbuild": "0.24.0",
91
+ "cross-fetch": "^4.1.0",
92
+ "esbuild": "0.24.2",
93
93
  "eslint": "8.57.0",
94
94
  "eslint-plugin-deprecation": "^3.0.0",
95
95
  "eslint-plugin-etc": "^2.0.3",
96
96
  "eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
97
- "eslint-plugin-jsx-a11y": "^6.10.0",
97
+ "eslint-plugin-jsx-a11y": "^6.10.2",
98
98
  "eslint-plugin-mdx": "^3.1.5",
99
- "eslint-plugin-react": "^7.37.1",
100
- "eslint-plugin-react-hooks": "^4.6.2",
99
+ "eslint-plugin-react": "^7.37.3",
100
+ "eslint-plugin-react-hooks": "^5.1.0",
101
101
  "eslint-plugin-ssr-friendly": "^1.3.0",
102
- "eslint-plugin-testing-library": "^6.3.0",
102
+ "eslint-plugin-testing-library": "^7.1.1",
103
103
  "eslint-plugin-validate-jsx-nesting": "^0.1.1",
104
104
  "eslint-plugin-vitest": "^0.4.1",
105
105
  "eslint-plugin-vitest-globals": "^1.5.0",
106
- "msw": "^2.4.9",
106
+ "msw": "^2.7.0",
107
107
  "next": "^14.2.4",
108
- "node-mocks-http": "^1.16.1",
109
- "prettier": "^3.3.3",
110
- "react": "^18.3.1",
111
- "react-dom": "^18.3.1",
112
- "rimraf": "5.0.9",
113
- "semantic-release": "24.0.0",
114
- "typescript": "5.4.5",
115
- "vitest": "^2.1.2"
108
+ "node-mocks-http": "^1.16.2",
109
+ "prettier": "^3.4.2",
110
+ "react": "^19.0.0",
111
+ "react-dom": "^19.0.0",
112
+ "rimraf": "6.0.1",
113
+ "semantic-release": "24.2.1",
114
+ "typescript": "5.7.3",
115
+ "vitest": "^2.1.8"
116
116
  },
117
117
  "optionalDependencies": {
118
- "next": "^14.2.4"
118
+ "next": ">=15.1"
119
119
  },
120
120
  "engines": {
121
- "node": ">=18.* <=22.*"
121
+ "node": ">=18.* <=23.*"
122
122
  },
123
123
  "os": [
124
124
  "darwin",
@@ -1 +0,0 @@
1
- var i=Object.defineProperty;var s=(h,e)=>i(h,"name",{value:e,configurable:!0});var l=Object.defineProperty,n=s((h,e)=>l(h,"name",{value:e,configurable:!0}),"s");class k{static{s(this,"i")}static{n(this,"Healthcheck")}healthCheckers={};addChecker(e,t){this.healthCheckers[e]=t}async getReport(){const e={};return await Promise.all(Object.keys(this.healthCheckers).map(async t=>await this.invokeChecker(t,e))),{healthy:!Object.keys(e).find(t=>!e[t].health.healthy),report:e}}async isLive(){const{healthy:e}=await this.getReport();return e}get servicesList(){return Object.keys(this.healthCheckers)}async invokeChecker(e,t){const r=this.healthCheckers[e];let a;try{a=await r(),a.displayName=a.displayName||e}catch(c){a={displayName:e,health:{healthy:!1,message:c.message,timestamp:new Date().toISOString()},meta:{fatal:!0}}}return t[e]=a,a.health.healthy}}export{k as default};
@@ -1 +0,0 @@
1
- "use strict";var i=Object.defineProperty;var s=(h,e)=>i(h,"name",{value:e,configurable:!0});var l=Object.defineProperty,n=s((h,e)=>l(h,"name",{value:e,configurable:!0}),"s");class y{static{s(this,"i")}static{n(this,"Healthcheck")}healthCheckers={};addChecker(e,t){this.healthCheckers[e]=t}async getReport(){const e={};return await Promise.all(Object.keys(this.healthCheckers).map(async t=>await this.invokeChecker(t,e))),{healthy:!Object.keys(e).find(t=>!e[t].health.healthy),report:e}}async isLive(){const{healthy:e}=await this.getReport();return e}get servicesList(){return Object.keys(this.healthCheckers)}async invokeChecker(e,t){const r=this.healthCheckers[e];let a;try{a=await r(),a.displayName=a.displayName||e}catch(c){a={displayName:e,health:{healthy:!1,message:c.message,timestamp:new Date().toISOString()},meta:{fatal:!0}}}return t[e]=a,a.health.healthy}}module.exports=y;
@@ -1 +0,0 @@
1
- "use strict";var c=Object.defineProperty;var r=(e,a)=>c(e,"name",{value:a,configurable:!0});const h=require("cacheable-lookup"),m=r(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),y=m(h);var p=Object.defineProperty,u=r((e,a)=>p(e,"name",{value:a,configurable:!0}),"n");const s="DNS check for",$=u((e,a,l)=>async()=>{const{family:n="all",hints:o,...i}=l??{},d=new y(i);try{const t=await d.lookupAsync(e.replace(/^https?:\/\//,""),{hints:o,...n==="all"?{all:!0}:{family:n}});return Array.isArray(a)&&!a.includes(t.address)?{displayName:`${s} ${e}`,health:{healthy:!1,message:`${s} ${e} returned address ${t.address} instead of ${a.join(", ")}.`,timestamp:new Date().toISOString()},meta:{addresses:t,host:e}}:{displayName:`${s} ${e}`,health:{healthy:!0,message:`${s} ${e} were resolved.`,timestamp:new Date().toISOString()},meta:{addresses:t,host:e}}}catch(t){return{displayName:`${s} ${e}`,health:{healthy:!1,message:t.message,timestamp:new Date().toISOString()},meta:{host:e}}}},"dnsCheck");module.exports=$;
@@ -1 +0,0 @@
1
- var o=Object.defineProperty;var l=(a,e)=>o(a,"name",{value:e,configurable:!0});import d from"cacheable-lookup";var c=Object.defineProperty,y=l((a,e)=>c(a,"name",{value:e,configurable:!0}),"n");const t="DNS check for",f=y((a,e,n)=>async()=>{const{family:r="all",hints:m,...h}=n??{},i=new d(h);try{const s=await i.lookupAsync(a.replace(/^https?:\/\//,""),{hints:m,...r==="all"?{all:!0}:{family:r}});return Array.isArray(e)&&!e.includes(s.address)?{displayName:`${t} ${a}`,health:{healthy:!1,message:`${t} ${a} returned address ${s.address} instead of ${e.join(", ")}.`,timestamp:new Date().toISOString()},meta:{addresses:s,host:a}}:{displayName:`${t} ${a}`,health:{healthy:!0,message:`${t} ${a} were resolved.`,timestamp:new Date().toISOString()},meta:{addresses:s,host:a}}}catch(s){return{displayName:`${t} ${a}`,health:{healthy:!1,message:s.message,timestamp:new Date().toISOString()},meta:{host:a}}}},"dnsCheck");export{f as default};
@@ -1 +0,0 @@
1
- "use strict";var p=Object.defineProperty;var n=(e,t)=>p(e,"name",{value:t,configurable:!0});const o=require("http-status-codes");var u=Object.defineProperty,i=n((e,t)=>u(e,"name",{value:t,configurable:!0}),"a");const l=i((e,t=!0)=>async(h,s)=>{const{healthy:a,report:r}=await e.getReport(),c={appName:process.env.APP_NAME??"unknown",appVersion:process.env.APP_VERSION??"unknown",message:a?"Health check successful":"Health check failed",reports:r,status:a?"ok":"error",timestamp:new Date().toISOString()};s.statusCode=a?o.StatusCodes.OK:o.StatusCodes.SERVICE_UNAVAILABLE,t&&s.setHeader("Content-Type","application/json"),s.end(JSON.stringify(c,null,2))},"default");module.exports=l;
@@ -1 +0,0 @@
1
- var p=Object.defineProperty;var o=(e,t)=>p(e,"name",{value:t,configurable:!0});import{StatusCodes as r}from"http-status-codes";var i=Object.defineProperty,l=o((e,t)=>i(e,"name",{value:t,configurable:!0}),"a");const f=l((e,t=!0)=>async(u,a)=>{const{healthy:n,report:s}=await e.getReport(),c={appName:process.env.APP_NAME??"unknown",appVersion:process.env.APP_VERSION??"unknown",message:n?"Health check successful":"Health check failed",reports:s,status:n?"ok":"error",timestamp:new Date().toISOString()};a.statusCode=n?r.OK:r.SERVICE_UNAVAILABLE,t&&a.setHeader("Content-Type","application/json"),a.end(JSON.stringify(c,null,2))},"default");export{f as default};
@@ -1 +0,0 @@
1
- var n=Object.defineProperty;var r=(e,t)=>n(e,"name",{value:t,configurable:!0});import{StatusCodes as o}from"http-status-codes";var s=Object.defineProperty,l=r((e,t)=>s(e,"name",{value:t,configurable:!0}),"o");const f=l(e=>async(t,a)=>{const{healthy:d}=await e.getReport();a.statusCode=d?o.NO_CONTENT:o.SERVICE_UNAVAILABLE,a.end()},"default");export{f as default};
@@ -1 +0,0 @@
1
- "use strict";var d=Object.defineProperty;var s=(t,e)=>d(t,"name",{value:e,configurable:!0});const r=require("http-status-codes");var n=Object.defineProperty,u=s((t,e)=>n(t,"name",{value:e,configurable:!0}),"o");const c=u(t=>async(e,a)=>{const{healthy:o}=await t.getReport();a.statusCode=o?r.StatusCodes.NO_CONTENT:r.StatusCodes.SERVICE_UNAVAILABLE,a.end()},"default");module.exports=c;
@@ -1 +0,0 @@
1
- var c=Object.defineProperty;var o=(e,t)=>c(e,"name",{value:t,configurable:!0});import{deepStrictEqual as d}from"node:assert";var i=Object.defineProperty,h=o((e,t)=>i(e,"name",{value:t,configurable:!0}),"c");const a="HTTP check for",p=h((e,t)=>async()=>{try{const s=await fetch(e,t?.fetchOptions??{});if(t?.expected?.status!==void 0&&t.expected.status!==s.status)throw new Error(`${a} ${e} returned status ${s.status} instead of ${t.expected.status}`);if(t?.expected?.body!==void 0){const r=await s.text();try{d(r,t.expected.body)}catch{throw new Error(`${a} ${e} returned body ${JSON.stringify(r)} instead of ${JSON.stringify(t.expected.body)}`)}}return{displayName:`${a} ${e}`,health:{healthy:!0,message:`${a} ${e} was successful.`,timestamp:new Date().toISOString()},meta:{host:e,method:t?.fetchOptions?.method??"GET",status:s.status}}}catch(s){return{displayName:`${a} ${e}`,health:{healthy:!1,message:s.message,timestamp:new Date().toISOString()},meta:{host:e,method:t?.fetchOptions?.method??"GET"}}}},"httpCheck");export{p as default};
@@ -1 +0,0 @@
1
- "use strict";var c=Object.defineProperty;var o=(e,t)=>c(e,"name",{value:t,configurable:!0});const i=require("node:assert");var d=Object.defineProperty,n=o((e,t)=>d(e,"name",{value:t,configurable:!0}),"c");const a="HTTP check for",h=n((e,t)=>async()=>{try{const s=await fetch(e,t?.fetchOptions??{});if(t?.expected?.status!==void 0&&t.expected.status!==s.status)throw new Error(`${a} ${e} returned status ${s.status} instead of ${t.expected.status}`);if(t?.expected?.body!==void 0){const r=await s.text();try{i.deepStrictEqual(r,t.expected.body)}catch{throw new Error(`${a} ${e} returned body ${JSON.stringify(r)} instead of ${JSON.stringify(t.expected.body)}`)}}return{displayName:`${a} ${e}`,health:{healthy:!0,message:`${a} ${e} was successful.`,timestamp:new Date().toISOString()},meta:{host:e,method:t?.fetchOptions?.method??"GET",status:s.status}}}catch(s){return{displayName:`${a} ${e}`,health:{healthy:!1,message:s.message,timestamp:new Date().toISOString()},meta:{host:e,method:t?.fetchOptions?.method??"GET"}}}},"httpCheck");module.exports=h;
@@ -1 +0,0 @@
1
- var o=Object.defineProperty;var n=(t,e)=>o(t,"name",{value:e,configurable:!0});var r=Object.defineProperty,s=n((t,e)=>r(t,"name",{value:e,configurable:!0}),"i");const i="Node Environment Check",l=s(t=>async()=>{const e="production";let a;return t!==void 0&&e!==t&&(a=`NODE_ENV environment variable is set to "${e}" instead of "${t}".`),a!==void 0?{displayName:i,health:{healthy:!1,message:a,timestamp:new Date().toISOString()}}:{displayName:i,health:{healthy:!0,timestamp:new Date().toISOString()},meta:{env:e}}},"nodeEnvironmentCheck");export{l as default};
@@ -1 +0,0 @@
1
- "use strict";var o=Object.defineProperty;var n=(t,e)=>o(t,"name",{value:e,configurable:!0});var r=Object.defineProperty,s=n((t,e)=>r(t,"name",{value:e,configurable:!0}),"i");const i="Node Environment Check",m=s(t=>async()=>{const e="production";let a;return t!==void 0&&e!==t&&(a=`NODE_ENV environment variable is set to "${e}" instead of "${t}".`),a!==void 0?{displayName:i,health:{healthy:!1,message:a,timestamp:new Date().toISOString()}}:{displayName:i,health:{healthy:!0,timestamp:new Date().toISOString()},meta:{env:e}}},"nodeEnvironmentCheck");module.exports=m;
@@ -1 +0,0 @@
1
- "use strict";var n=Object.defineProperty;var i=(t,e)=>n(t,"name",{value:e,configurable:!0});const r=require("pingman"),l=i(t=>t&&typeof t=="object"&&"default"in t?t.default:t,"_interopDefaultCompat"),c=l(r);var m=Object.defineProperty,o=i((t,e)=>m(t,"name",{value:e,configurable:!0}),"n");const s="Ping check for",h=o((t,e)=>async()=>{try{const a=await c(t.replace(/^https?:\/\//,""),e);return a.alive?{displayName:`${s} ${t}`,health:{healthy:!0,message:`${s} ${t} was successful.`,timestamp:new Date().toISOString()},meta:a}:{displayName:`${s} ${t}`,health:{healthy:!1,message:`Ping failed for ${t}.`,timestamp:new Date().toISOString()},meta:a}}catch(a){return{displayName:`${s} ${t}`,health:{healthy:!1,message:a.message,timestamp:new Date().toISOString()}}}},"pingCheck");module.exports=h;
@@ -1 +0,0 @@
1
- var m=Object.defineProperty;var i=(e,a)=>m(e,"name",{value:a,configurable:!0});import r from"pingman";var n=Object.defineProperty,h=i((e,a)=>n(e,"name",{value:a,configurable:!0}),"n");const s="Ping check for",o=h((e,a)=>async()=>{try{const t=await r(e.replace(/^https?:\/\//,""),a);return t.alive?{displayName:`${s} ${e}`,health:{healthy:!0,message:`${s} ${e} was successful.`,timestamp:new Date().toISOString()},meta:t}:{displayName:`${s} ${e}`,health:{healthy:!1,message:`Ping failed for ${e}.`,timestamp:new Date().toISOString()},meta:t}}catch(t){return{displayName:`${s} ${e}`,health:{healthy:!1,message:t.message,timestamp:new Date().toISOString()}}}},"pingCheck");export{o as default};