@visulima/health-check 2.0.18 → 2.0.20
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 +26 -0
- package/README.md +1 -1
- package/dist/index.cjs +21 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +7 -1
- package/dist/packem_shared/HealthCheck-B5xOyzcA.cjs +57 -0
- package/dist/packem_shared/HealthCheck-nWvpT85r.mjs +55 -0
- package/dist/packem_shared/dnsCheck-CKpwi39o.cjs +64 -0
- package/dist/packem_shared/dnsCheck-DJXOtLo2.mjs +58 -0
- package/dist/packem_shared/healthCheckHandler-BIIllStf.cjs +24 -0
- package/dist/packem_shared/healthCheckHandler-C0NYbHG_.mjs +22 -0
- package/dist/packem_shared/healthReadyHandler-Bd4123kn.mjs +11 -0
- package/dist/packem_shared/healthReadyHandler-vdf1928k.cjs +13 -0
- package/dist/packem_shared/httpCheck-CmLmorh2.cjs +53 -0
- package/dist/packem_shared/httpCheck-ivA5vEeE.mjs +51 -0
- package/dist/packem_shared/nodeEnvCheck-C2C9wY2Q.cjs +36 -0
- package/dist/packem_shared/nodeEnvCheck-CYVfgkJ_.mjs +34 -0
- package/dist/packem_shared/pingCheck-CYOzCjjQ.cjs +49 -0
- package/dist/packem_shared/pingCheck-W2tp3p2k.mjs +43 -0
- package/package.json +3 -74
- package/dist/packem_shared/HealthCheck-CypoYHvz.mjs +0 -1
- package/dist/packem_shared/HealthCheck-DQvQhFYY.cjs +0 -1
- package/dist/packem_shared/dnsCheck-CN6R59pd.cjs +0 -1
- package/dist/packem_shared/dnsCheck-G72qe__U.mjs +0 -1
- package/dist/packem_shared/healthCheckHandler-BH0Fcvsh.cjs +0 -1
- package/dist/packem_shared/healthCheckHandler-BdYk897h.mjs +0 -1
- package/dist/packem_shared/healthReadyHandler-D_Z0BVtR.mjs +0 -1
- package/dist/packem_shared/healthReadyHandler-DjRXCune.cjs +0 -1
- package/dist/packem_shared/httpCheck-BNlBtiV7.mjs +0 -1
- package/dist/packem_shared/httpCheck-DT6HrAPG.cjs +0 -1
- package/dist/packem_shared/nodeEnvCheck-BxNJ8ArD.mjs +0 -1
- package/dist/packem_shared/nodeEnvCheck-aT51eSWt.cjs +0 -1
- package/dist/packem_shared/pingCheck-DIrh3Cwy.cjs +0 -1
- package/dist/packem_shared/pingCheck-DWJlRAgo.mjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## @visulima/health-check [2.0.20](https://github.com/visulima/visulima/compare/@visulima/health-check@2.0.19...@visulima/health-check@2.0.20) (2025-01-25)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* fixed wrong node version range in package.json ([4ae2929](https://github.com/visulima/visulima/commit/4ae292984681c71a770e4d4560432f7b7c5a141a))
|
|
6
|
+
|
|
7
|
+
### Miscellaneous Chores
|
|
8
|
+
|
|
9
|
+
* fixed typescript url ([fe65a8c](https://github.com/visulima/visulima/commit/fe65a8c0296ece7ee26474c70d065b06d4d0da89))
|
|
10
|
+
* updated all dev dependencies ([37fb298](https://github.com/visulima/visulima/commit/37fb298b2af7c63be64252024e54bb3af6ddabec))
|
|
11
|
+
* updated all dev dependencies and all dependencies in the app folder ([87f4ccb](https://github.com/visulima/visulima/commit/87f4ccbf9f7900ec5b56f3c1477bc4a0ef571bcf))
|
|
12
|
+
|
|
13
|
+
### Tests
|
|
14
|
+
|
|
15
|
+
* **health-check:** improved test of dns check ([47d60cd](https://github.com/visulima/visulima/commit/47d60cdd5b8d2959620de278cfe85ac910f7dd2d))
|
|
16
|
+
|
|
17
|
+
## @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)
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* updated @visulima/packem, and all other dev dependencies ([7797a1c](https://github.com/visulima/visulima/commit/7797a1c3e6f1fc532895247bd88285a8a9883c40))
|
|
22
|
+
|
|
23
|
+
### Miscellaneous Chores
|
|
24
|
+
|
|
25
|
+
* updated dev dependencies ([9de2eab](https://github.com/visulima/visulima/commit/9de2eab91e95c8b9289d12f863a5167218770650))
|
|
26
|
+
|
|
1
27
|
## @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)
|
|
2
28
|
|
|
3
29
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -197,7 +197,7 @@ If you would like to help take a look at the [list of issues](https://github.com
|
|
|
197
197
|
The visulima health-check is open-sourced software licensed under the [MIT][license-url]
|
|
198
198
|
|
|
199
199
|
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
|
|
200
|
-
[typescript-url]: "typescript"
|
|
200
|
+
[typescript-url]: https://www.typescriptlang.org/ "TypeScript" "typescript"
|
|
201
201
|
[license-image]: https://img.shields.io/npm/l/@visulima/health-check?color=blueviolet&style=for-the-badge
|
|
202
202
|
[license-url]: LICENSE.md "license"
|
|
203
203
|
[npm-image]: https://img.shields.io/npm/v/@visulima/health-check/latest.svg?style=for-the-badge&logo=npm
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "2.0.20",
|
|
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",
|
|
@@ -72,53 +72,11 @@
|
|
|
72
72
|
"http-status-codes": "^2.3.0",
|
|
73
73
|
"pingman": "^2.0.0"
|
|
74
74
|
},
|
|
75
|
-
"devDependencies": {
|
|
76
|
-
"@anolilab/eslint-config": "^15.0.3",
|
|
77
|
-
"@anolilab/prettier-config": "^5.0.14",
|
|
78
|
-
"@anolilab/semantic-release-pnpm": "^1.1.5",
|
|
79
|
-
"@anolilab/semantic-release-preset": "^9.0.2",
|
|
80
|
-
"@arethetypeswrong/cli": "^0.17.1",
|
|
81
|
-
"@arthurgeron/eslint-plugin-react-usememo": "^2.4.4",
|
|
82
|
-
"@babel/core": "^7.26.0",
|
|
83
|
-
"@rushstack/eslint-plugin-security": "^0.8.3",
|
|
84
|
-
"@testing-library/react": "^16.1.0",
|
|
85
|
-
"@types/node": "18.19.15",
|
|
86
|
-
"@visulima/packem": "1.9.2",
|
|
87
|
-
"@vitest/coverage-v8": "^2.1.8",
|
|
88
|
-
"@vitest/ui": "^2.1.8",
|
|
89
|
-
"conventional-changelog-conventionalcommits": "8.0.0",
|
|
90
|
-
"cross-env": "^7.0.3",
|
|
91
|
-
"cross-fetch": "^4.0.0",
|
|
92
|
-
"esbuild": "0.24.0",
|
|
93
|
-
"eslint": "8.57.0",
|
|
94
|
-
"eslint-plugin-deprecation": "^3.0.0",
|
|
95
|
-
"eslint-plugin-etc": "^2.0.3",
|
|
96
|
-
"eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
|
|
97
|
-
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
98
|
-
"eslint-plugin-mdx": "^3.1.5",
|
|
99
|
-
"eslint-plugin-react": "^7.37.2",
|
|
100
|
-
"eslint-plugin-react-hooks": "^5.1.0",
|
|
101
|
-
"eslint-plugin-ssr-friendly": "^1.3.0",
|
|
102
|
-
"eslint-plugin-testing-library": "^7.1.1",
|
|
103
|
-
"eslint-plugin-validate-jsx-nesting": "^0.1.1",
|
|
104
|
-
"eslint-plugin-vitest": "^0.4.1",
|
|
105
|
-
"eslint-plugin-vitest-globals": "^1.5.0",
|
|
106
|
-
"msw": "^2.6.8",
|
|
107
|
-
"next": "^14.2.4",
|
|
108
|
-
"node-mocks-http": "^1.16.2",
|
|
109
|
-
"prettier": "^3.4.2",
|
|
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.8"
|
|
116
|
-
},
|
|
117
75
|
"optionalDependencies": {
|
|
118
|
-
"next": ">=
|
|
76
|
+
"next": ">=15.1"
|
|
119
77
|
},
|
|
120
78
|
"engines": {
|
|
121
|
-
"node": ">=18
|
|
79
|
+
"node": ">=18.0.0 <=23.x"
|
|
122
80
|
},
|
|
123
81
|
"os": [
|
|
124
82
|
"darwin",
|
|
@@ -128,34 +86,5 @@
|
|
|
128
86
|
"publishConfig": {
|
|
129
87
|
"access": "public",
|
|
130
88
|
"provenance": true
|
|
131
|
-
},
|
|
132
|
-
"anolilab": {
|
|
133
|
-
"eslint-config": {
|
|
134
|
-
"plugin": {
|
|
135
|
-
"tsdoc": false
|
|
136
|
-
},
|
|
137
|
-
"warn_on_unsupported_typescript_version": false,
|
|
138
|
-
"info_on_disabling_jsx_react_rule": false,
|
|
139
|
-
"info_on_disabling_prettier_conflict_rule": false,
|
|
140
|
-
"info_on_disabling_jsonc_sort_keys_rule": false,
|
|
141
|
-
"info_on_disabling_etc_no_deprecated": false
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
"scripts": {
|
|
145
|
-
"build": "cross-env NODE_ENV=development packem build",
|
|
146
|
-
"build:prod": "cross-env NODE_ENV=production packem build",
|
|
147
|
-
"clean": "rimraf node_modules dist .eslintcache",
|
|
148
|
-
"dev": "pnpm run build --watch",
|
|
149
|
-
"lint:attw": "attw --pack",
|
|
150
|
-
"lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs",
|
|
151
|
-
"lint:eslint:fix": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs --fix",
|
|
152
|
-
"lint:package-json": "publint --strict",
|
|
153
|
-
"lint:prettier": "prettier --config=.prettierrc.cjs --check .",
|
|
154
|
-
"lint:prettier:fix": "prettier --config=.prettierrc.cjs --write .",
|
|
155
|
-
"lint:types": "tsc --noEmit",
|
|
156
|
-
"test": "vitest run",
|
|
157
|
-
"test:coverage": "vitest run --coverage",
|
|
158
|
-
"test:ui": "vitest --ui --coverage.enabled=true",
|
|
159
|
-
"test:watch": "vitest"
|
|
160
89
|
}
|
|
161
90
|
}
|
|
@@ -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};
|