@boomerang-io/webapp-spa-server 1.3.4-beta.1 → 1.3.4-beta.2
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/index.js +18 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const cors = require("cors");
|
|
7
|
+
const http = require("http");
|
|
7
8
|
const serialize = require("serialize-javascript");
|
|
8
9
|
const boomerangLogger = require("@boomerang-io/logger-middleware")("webapp-spa-server/index.js");
|
|
9
10
|
const health = require("@cloudnative/health-connect");
|
|
@@ -53,7 +54,7 @@ function createBoomerangServer({
|
|
|
53
54
|
app.use(compression());
|
|
54
55
|
|
|
55
56
|
// Logging
|
|
56
|
-
app.use(boomerangLogger.
|
|
57
|
+
app.use(boomerangLogger.middleware);
|
|
57
58
|
|
|
58
59
|
// Security
|
|
59
60
|
const helmet = require("helmet");
|
|
@@ -75,7 +76,22 @@ function createBoomerangServer({
|
|
|
75
76
|
|
|
76
77
|
// Initialize healthchecker and add routes
|
|
77
78
|
const healthchecker = new health.HealthChecker();
|
|
78
|
-
app.use("/health",
|
|
79
|
+
app.use("/health", (req, res, next) => {
|
|
80
|
+
healthchecker.getLivenessStatus().then((status) => {
|
|
81
|
+
logger.debug(status);
|
|
82
|
+
switch (status.status) {
|
|
83
|
+
case "STARTING":
|
|
84
|
+
case "UP":
|
|
85
|
+
// res.statusCode = 200; break;
|
|
86
|
+
break;
|
|
87
|
+
default:
|
|
88
|
+
res.statusCode = 503;
|
|
89
|
+
res.write(JSON.stringify(status));
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
res.end();
|
|
93
|
+
}).catch((err) => {res.end()});
|
|
94
|
+
});
|
|
79
95
|
app.use("/ready", health.ReadinessEndpoint(healthchecker));
|
|
80
96
|
|
|
81
97
|
// Create endpoint for the app serve static assets
|
package/package.json
CHANGED