@sera4/essentia 1.0.11 → 1.0.12
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/health/index.js +12 -2
- package/package.json +1 -1
- package/package.tar.gz +0 -0
package/health/index.js
CHANGED
|
@@ -21,13 +21,16 @@ class HealthCheckError extends Error {
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
class HealthCheck {
|
|
24
|
-
constructor() {
|
|
24
|
+
constructor(appendData = {}) {
|
|
25
25
|
this.defaultResponse = {
|
|
26
|
+
...
|
|
27
|
+
appendData,
|
|
26
28
|
status: 200,
|
|
27
29
|
errors: {}
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
this.defaultPathRoute = `health_check\(.*\)?`
|
|
33
|
+
this.lastCallID = null;
|
|
31
34
|
|
|
32
35
|
this.healthChecks = [];
|
|
33
36
|
}
|
|
@@ -69,6 +72,9 @@ class HealthCheck {
|
|
|
69
72
|
}));
|
|
70
73
|
|
|
71
74
|
//let result = (result.reduce((e) => e.success, 200))
|
|
75
|
+
let callId = (Math.random()*0xFFFFFF<<0).toString(16);
|
|
76
|
+
this.lastCallId = callId;
|
|
77
|
+
|
|
72
78
|
let status = this.defaultResponse.status;
|
|
73
79
|
|
|
74
80
|
result.some(e => {
|
|
@@ -78,15 +84,19 @@ class HealthCheck {
|
|
|
78
84
|
}
|
|
79
85
|
})
|
|
80
86
|
|
|
87
|
+
// set this in the header no matter what
|
|
88
|
+
res.setHeader('check', callId)
|
|
89
|
+
|
|
81
90
|
if (checkFormat === ".json") {
|
|
82
91
|
if (status === 200) {
|
|
83
92
|
res.status(status).json({
|
|
93
|
+
"check": callId,
|
|
84
94
|
"healthy":true,
|
|
85
|
-
|
|
86
95
|
"message":"success"
|
|
87
96
|
});
|
|
88
97
|
} else {
|
|
89
98
|
res.status(status).json({
|
|
99
|
+
"check": callId,
|
|
90
100
|
"healthy": false,
|
|
91
101
|
"message": "fail",
|
|
92
102
|
"services": [result]
|
package/package.json
CHANGED
package/package.tar.gz
CHANGED
|
Binary file
|