@visulima/health-check 2.0.22 → 3.0.0
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 +17 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -0
- package/dist/packem_shared/HealthCheck-CypoYHvz.js +1 -0
- package/dist/packem_shared/dnsCheck-DmKC-X1P.js +1 -0
- package/dist/packem_shared/healthCheckHandler-l2w9DVbg.js +1 -0
- package/dist/packem_shared/healthReadyHandler-DV7Ch0fg.js +1 -0
- package/dist/packem_shared/httpCheck-Dzf65hZl.js +1 -0
- package/dist/packem_shared/nodeEnvCheck-DPysE7_-.js +1 -0
- package/dist/packem_shared/pingCheck-kq5XiIFg.js +1 -0
- package/package.json +4 -23
- package/dist/index.cjs +0 -21
- package/dist/index.d.cts +0 -62
- package/dist/index.d.mts +0 -60
- package/dist/index.mjs +0 -7
- package/dist/packem_shared/HealthCheck-B5xOyzcA.cjs +0 -57
- package/dist/packem_shared/HealthCheck-nWvpT85r.mjs +0 -55
- package/dist/packem_shared/dnsCheck-CKpwi39o.cjs +0 -64
- package/dist/packem_shared/dnsCheck-DJXOtLo2.mjs +0 -58
- package/dist/packem_shared/healthCheckHandler-BIIllStf.cjs +0 -24
- package/dist/packem_shared/healthCheckHandler-C0NYbHG_.mjs +0 -22
- package/dist/packem_shared/healthReadyHandler-Bd4123kn.mjs +0 -11
- package/dist/packem_shared/healthReadyHandler-vdf1928k.cjs +0 -13
- package/dist/packem_shared/httpCheck-BS8O0ZEs.cjs +0 -53
- package/dist/packem_shared/httpCheck-hHYnlgcd.mjs +0 -51
- package/dist/packem_shared/nodeEnvCheck-Cjo3FyXK.mjs +0 -34
- package/dist/packem_shared/nodeEnvCheck-DcTXz_-V.cjs +0 -36
- package/dist/packem_shared/pingCheck-CYOzCjjQ.cjs +0 -49
- package/dist/packem_shared/pingCheck-W2tp3p2k.mjs +0 -43
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## @visulima/health-check [3.0.0](https://github.com/visulima/visulima/compare/@visulima/health-check@2.0.22...@visulima/health-check@3.0.0) (2025-10-15)
|
|
2
|
+
|
|
3
|
+
### ⚠ BREAKING CHANGES
|
|
4
|
+
|
|
5
|
+
* Adjusted the node engine requirement to support versions 20.19 and above
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* Adjusted the node engine requirement to support versions 20.19 and above ([7026e7e](https://github.com/visulima/visulima/commit/7026e7ea4b42c691696c059c3d07aa41c24c171d))
|
|
10
|
+
* update @visulima/packem to 2.0.0-alpha.30 across multiple packages for improved compatibility ([27b346e](https://github.com/visulima/visulima/commit/27b346eaa1c0fb0e420d9a9824482028307f4249))
|
|
11
|
+
|
|
12
|
+
### Miscellaneous Chores
|
|
13
|
+
|
|
14
|
+
* **deps:** update build scripts and remove cross-env dependency ([7510e82](https://github.com/visulima/visulima/commit/7510e826b9235a0013fe61c82a7eb333bc4cbb78))
|
|
15
|
+
* update package dependencies across multiple packages for improved compatibility and performance ([9567591](https://github.com/visulima/visulima/commit/9567591c415da3002f3a4fe08f8caf7ce01ca5f7))
|
|
16
|
+
* update package.json and pnpm-lock.yaml to include publint@0.3.12 and adjust build/test commands to exclude shared-utils ([1f7b3c0](https://github.com/visulima/visulima/commit/1f7b3c0381d77edfeec80ea1bf57b3469e929414))
|
|
17
|
+
|
|
1
18
|
## @visulima/health-check [2.0.22](https://github.com/visulima/visulima/compare/@visulima/health-check@2.0.21...@visulima/health-check@2.0.22) (2025-05-30)
|
|
2
19
|
|
|
3
20
|
### Bug Fixes
|
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,5 @@ declare class Healthcheck implements HealthCheck {
|
|
|
57
57
|
private invokeChecker;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export {
|
|
61
|
-
|
|
62
|
-
export = as healthReadyHandler;
|
|
60
|
+
export { Healthcheck as HealthCheck, dnsCheck, _default$1 as healthCheckHandler, _default as healthReadyHandler, httpCheck, nodeEnvironmentCheck as nodeEnvCheck, pingCheck };
|
|
61
|
+
export type { Checker };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as t}from"./packem_shared/dnsCheck-DmKC-X1P.js";import{default as o}from"./packem_shared/httpCheck-Dzf65hZl.js";import{default as d}from"./packem_shared/nodeEnvCheck-DPysE7_-.js";import{default as l}from"./packem_shared/pingCheck-kq5XiIFg.js";import{default as s}from"./packem_shared/healthCheckHandler-l2w9DVbg.js";import{default as u}from"./packem_shared/healthReadyHandler-DV7Ch0fg.js";import{default as c}from"./packem_shared/HealthCheck-CypoYHvz.js";export{c as HealthCheck,t as dnsCheck,s as healthCheckHandler,u as healthReadyHandler,o as httpCheck,d as nodeEnvCheck,l as pingCheck};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o=Object.defineProperty;var l=(e,a)=>o(e,"name",{value:a,configurable:!0});import d from"cacheable-lookup";var c=Object.defineProperty,y=l((e,a)=>c(e,"name",{value:a,configurable:!0}),"n");const s="DNS check for",u=y((e,a,n)=>async()=>{const{family:r="all",hints:m,...h}=n??{},i=new d(h);try{const t=await i.lookupAsync(e.replace(/^https?:\/\//,""),{hints:m,...r==="all"?{all:!0}:{family:r}});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");export{u as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=Object.defineProperty;var r=(e,t)=>c(e,"name",{value:t,configurable:!0});import{createRequire as u}from"node:module";const p=u(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const{StatusCodes:n}=p("http-status-codes");var l=Object.defineProperty,d=r((e,t)=>l(e,"name",{value:t,configurable:!0}),"a");const g=d((e,t=!0)=>async(f,s)=>{const{healthy:o,report:a}=await e.getReport(),i={appName:process.env.APP_NAME??"unknown",appVersion:process.env.APP_VERSION??"unknown",message:o?"Health check successful":"Health check failed",reports:a,status:o?"ok":"error",timestamp:new Date().toISOString()};s.statusCode=o?n.OK:n.SERVICE_UNAVAILABLE,t&&s.setHeader("Content-Type","application/json"),s.end(JSON.stringify(i,null,2))},"default");export{g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=Object.defineProperty;var o=(e,t)=>a(e,"name",{value:t,configurable:!0});import{createRequire as i}from"node:module";const c=i(import.meta.url),_=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const{StatusCodes:r}=c("http-status-codes");var u=Object.defineProperty,d=o((e,t)=>u(e,"name",{value:t,configurable:!0}),"o");const f=d(e=>async(t,s)=>{const{healthy:n}=await e.getReport();s.statusCode=n?r.NO_CONTENT:r.SERVICE_UNAVAILABLE,s.end()},"default");export{f as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=Object.defineProperty;var a=(t,e)=>n(t,"name",{value:e,configurable:!0});import{createRequire as c}from"node:module";const d=c(import.meta.url),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=a(t=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[e,s]=r.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return r.getBuiltinModule(t)}return d(t)},"__cjs_getBuiltinModule"),{deepStrictEqual:h}=u("node:assert");var p=Object.defineProperty,f=a((t,e)=>p(t,"name",{value:e,configurable:!0}),"c");const o="HTTP check for",y=f((t,e)=>async()=>{try{const s=await fetch(t,e?.fetchOptions??{});if(e?.expected?.status!==void 0&&e.expected.status!==s.status)throw new Error(`${o} ${t} returned status ${s.status} instead of ${e.expected.status}`);if(e?.expected?.body!==void 0){const i=await s.text();try{h(i,e.expected.body)}catch{throw new Error(`${o} ${t} returned body ${JSON.stringify(i)} instead of ${JSON.stringify(e.expected.body)}`)}}return{displayName:`${o} ${t}`,health:{healthy:!0,message:`${o} ${t} was successful.`,timestamp:new Date().toISOString()},meta:{host:t,method:e?.fetchOptions?.method??"GET",status:s.status}}}catch(s){return{displayName:`${o} ${t}`,health:{healthy:!1,message:s.message,timestamp:new Date().toISOString()},meta:{host:t,method:e?.fetchOptions?.method??"GET"}}}},"httpCheck");export{y as default};
|
|
@@ -0,0 +1 @@
|
|
|
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",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");export{m as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var r=(e,t)=>i(e,"name",{value:t,configurable:!0});import{createRequire as n}from"node:module";const o=n(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const l=o("pingman");var c=Object.defineProperty,m=r((e,t)=>c(e,"name",{value:t,configurable:!0}),"n");const a="Ping check for",f=m((e,t)=>async()=>{try{const s=await l(e.replace(/^https?:\/\//,""),t);return s.alive?{displayName:`${a} ${e}`,health:{healthy:!0,message:`${a} ${e} was successful.`,timestamp:new Date().toISOString()},meta:s}:{displayName:`${a} ${e}`,health:{healthy:!1,message:`Ping failed for ${e}.`,timestamp:new Date().toISOString()},meta:s}}catch(s){return{displayName:`${a} ${e}`,health:{healthy:!1,message:s.message,timestamp:new Date().toISOString()}}}},"pingCheck");export{f as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/health-check",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
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",
|
|
@@ -40,27 +40,11 @@
|
|
|
40
40
|
"type": "module",
|
|
41
41
|
"exports": {
|
|
42
42
|
".": {
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
"default": "./dist/index.cjs"
|
|
46
|
-
},
|
|
47
|
-
"import": {
|
|
48
|
-
"types": "./dist/index.d.mts",
|
|
49
|
-
"default": "./dist/index.mjs"
|
|
50
|
-
}
|
|
43
|
+
"types": "./dist/index.d.ts",
|
|
44
|
+
"default": "./dist/index.js"
|
|
51
45
|
},
|
|
52
46
|
"./package.json": "./package.json"
|
|
53
47
|
},
|
|
54
|
-
"main": "dist/index.cjs",
|
|
55
|
-
"module": "dist/index.mjs",
|
|
56
|
-
"types": "dist/index.d.ts",
|
|
57
|
-
"typesVersions": {
|
|
58
|
-
">=5.0": {
|
|
59
|
-
".": [
|
|
60
|
-
"./dist/index.d.ts"
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
48
|
"files": [
|
|
65
49
|
"dist/**",
|
|
66
50
|
"README.md",
|
|
@@ -72,11 +56,8 @@
|
|
|
72
56
|
"http-status-codes": "^2.3.0",
|
|
73
57
|
"pingman": "^2.0.0"
|
|
74
58
|
},
|
|
75
|
-
"optionalDependencies": {
|
|
76
|
-
"next": ">=15.3"
|
|
77
|
-
},
|
|
78
59
|
"engines": {
|
|
79
|
-
"node": ">=18.0.0 <=
|
|
60
|
+
"node": ">=18.0.0 <=24.x"
|
|
80
61
|
},
|
|
81
62
|
"os": [
|
|
82
63
|
"darwin",
|
package/dist/index.cjs
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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-BS8O0ZEs.cjs');
|
|
7
|
-
const nodeEnvCheck = require('./packem_shared/nodeEnvCheck-DcTXz_-V.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
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Options } from 'cacheable-lookup';
|
|
2
|
-
import { extendedPingOptions } from 'pingman';
|
|
3
|
-
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
4
|
-
|
|
5
|
-
interface HealthReportEntry {
|
|
6
|
-
displayName: string;
|
|
7
|
-
health: {
|
|
8
|
-
healthy: boolean;
|
|
9
|
-
message?: string;
|
|
10
|
-
timestamp: string;
|
|
11
|
-
};
|
|
12
|
-
meta?: any;
|
|
13
|
-
}
|
|
14
|
-
type Checker = () => Promise<HealthReportEntry>;
|
|
15
|
-
type HealthReport = Record<string, HealthReportEntry>;
|
|
16
|
-
interface HealthCheck {
|
|
17
|
-
addChecker: (service: string, checker: Checker) => void;
|
|
18
|
-
getReport: () => Promise<{
|
|
19
|
-
healthy: boolean;
|
|
20
|
-
report: HealthReport;
|
|
21
|
-
}>;
|
|
22
|
-
isLive: () => Promise<boolean>;
|
|
23
|
-
servicesList: string[];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface DnsOptions extends Options {
|
|
27
|
-
family?: "all" | 4 | 6;
|
|
28
|
-
hints?: number;
|
|
29
|
-
}
|
|
30
|
-
declare const dnsCheck: (host: string, expectedAddresses?: string[], options?: DnsOptions) => Checker;
|
|
31
|
-
|
|
32
|
-
declare const httpCheck: (host: RequestInfo | URL, options?: {
|
|
33
|
-
expected?: {
|
|
34
|
-
body?: string;
|
|
35
|
-
status?: number;
|
|
36
|
-
};
|
|
37
|
-
fetchOptions?: RequestInit;
|
|
38
|
-
}) => Checker;
|
|
39
|
-
|
|
40
|
-
declare const nodeEnvironmentCheck: (expectedEnvironment?: string) => Checker;
|
|
41
|
-
|
|
42
|
-
declare const pingCheck: (host: string, options?: extendedPingOptions) => Checker;
|
|
43
|
-
|
|
44
|
-
declare const _default$1: (healthCheck: HealthCheck, sendHeader?: boolean | undefined) => <Request extends IncomingMessage, Response extends ServerResponse>(_: Request, response: Response) => Promise<void>;
|
|
45
|
-
|
|
46
|
-
declare const _default: <Request extends IncomingMessage, Response extends ServerResponse>(healthCheck: HealthCheck) => (_request: Request, response: Response) => Promise<void>;
|
|
47
|
-
|
|
48
|
-
declare class Healthcheck implements HealthCheck {
|
|
49
|
-
private healthCheckers;
|
|
50
|
-
addChecker(service: string, checker: Checker): void;
|
|
51
|
-
getReport(): Promise<{
|
|
52
|
-
healthy: boolean;
|
|
53
|
-
report: HealthReport;
|
|
54
|
-
}>;
|
|
55
|
-
isLive(): Promise<boolean>;
|
|
56
|
-
get servicesList(): string[];
|
|
57
|
-
private invokeChecker;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { type Checker, Healthcheck as HealthCheck, dnsCheck, _default$1 as healthCheckHandler, _default as healthReadyHandler, httpCheck, nodeEnvironmentCheck as nodeEnvCheck, pingCheck };
|
|
61
|
-
|
|
62
|
-
export = as healthReadyHandler;
|
package/dist/index.d.mts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Options } from 'cacheable-lookup';
|
|
2
|
-
import { extendedPingOptions } from 'pingman';
|
|
3
|
-
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
4
|
-
|
|
5
|
-
interface HealthReportEntry {
|
|
6
|
-
displayName: string;
|
|
7
|
-
health: {
|
|
8
|
-
healthy: boolean;
|
|
9
|
-
message?: string;
|
|
10
|
-
timestamp: string;
|
|
11
|
-
};
|
|
12
|
-
meta?: any;
|
|
13
|
-
}
|
|
14
|
-
type Checker = () => Promise<HealthReportEntry>;
|
|
15
|
-
type HealthReport = Record<string, HealthReportEntry>;
|
|
16
|
-
interface HealthCheck {
|
|
17
|
-
addChecker: (service: string, checker: Checker) => void;
|
|
18
|
-
getReport: () => Promise<{
|
|
19
|
-
healthy: boolean;
|
|
20
|
-
report: HealthReport;
|
|
21
|
-
}>;
|
|
22
|
-
isLive: () => Promise<boolean>;
|
|
23
|
-
servicesList: string[];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface DnsOptions extends Options {
|
|
27
|
-
family?: "all" | 4 | 6;
|
|
28
|
-
hints?: number;
|
|
29
|
-
}
|
|
30
|
-
declare const dnsCheck: (host: string, expectedAddresses?: string[], options?: DnsOptions) => Checker;
|
|
31
|
-
|
|
32
|
-
declare const httpCheck: (host: RequestInfo | URL, options?: {
|
|
33
|
-
expected?: {
|
|
34
|
-
body?: string;
|
|
35
|
-
status?: number;
|
|
36
|
-
};
|
|
37
|
-
fetchOptions?: RequestInit;
|
|
38
|
-
}) => Checker;
|
|
39
|
-
|
|
40
|
-
declare const nodeEnvironmentCheck: (expectedEnvironment?: string) => Checker;
|
|
41
|
-
|
|
42
|
-
declare const pingCheck: (host: string, options?: extendedPingOptions) => Checker;
|
|
43
|
-
|
|
44
|
-
declare const _default$1: (healthCheck: HealthCheck, sendHeader?: boolean | undefined) => <Request extends IncomingMessage, Response extends ServerResponse>(_: Request, response: Response) => Promise<void>;
|
|
45
|
-
|
|
46
|
-
declare const _default: <Request extends IncomingMessage, Response extends ServerResponse>(healthCheck: HealthCheck) => (_request: Request, response: Response) => Promise<void>;
|
|
47
|
-
|
|
48
|
-
declare class Healthcheck implements HealthCheck {
|
|
49
|
-
private healthCheckers;
|
|
50
|
-
addChecker(service: string, checker: Checker): void;
|
|
51
|
-
getReport(): Promise<{
|
|
52
|
-
healthy: boolean;
|
|
53
|
-
report: HealthReport;
|
|
54
|
-
}>;
|
|
55
|
-
isLive(): Promise<boolean>;
|
|
56
|
-
get servicesList(): string[];
|
|
57
|
-
private invokeChecker;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { type Checker, Healthcheck as HealthCheck, dnsCheck, _default$1 as healthCheckHandler, _default as healthReadyHandler, httpCheck, nodeEnvironmentCheck as nodeEnvCheck, pingCheck };
|
package/dist/index.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { default as dnsCheck } from './packem_shared/dnsCheck-DJXOtLo2.mjs';
|
|
2
|
-
export { default as httpCheck } from './packem_shared/httpCheck-hHYnlgcd.mjs';
|
|
3
|
-
export { default as nodeEnvCheck } from './packem_shared/nodeEnvCheck-Cjo3FyXK.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';
|
|
@@ -1,57 +0,0 @@
|
|
|
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;
|
|
@@ -1,55 +0,0 @@
|
|
|
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 };
|
|
@@ -1,64 +0,0 @@
|
|
|
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;
|
|
@@ -1,58 +0,0 @@
|
|
|
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 };
|
|
@@ -1,24 +0,0 @@
|
|
|
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;
|
|
@@ -1,22 +0,0 @@
|
|
|
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 };
|
|
@@ -1,11 +0,0 @@
|
|
|
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 };
|
|
@@ -1,13 +0,0 @@
|
|
|
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;
|
|
@@ -1,53 +0,0 @@
|
|
|
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 !== void 0 && 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 !== void 0) {
|
|
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;
|
|
@@ -1,51 +0,0 @@
|
|
|
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 !== void 0 && 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 !== void 0) {
|
|
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 };
|
|
@@ -1,34 +0,0 @@
|
|
|
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 !== void 0 && expectedEnvironment !== void 0 && 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 !== void 0) {
|
|
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 };
|
|
@@ -1,36 +0,0 @@
|
|
|
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 !== void 0 && expectedEnvironment !== void 0 && 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 !== void 0) {
|
|
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;
|
|
@@ -1,49 +0,0 @@
|
|
|
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;
|
|
@@ -1,43 +0,0 @@
|
|
|
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 };
|