diff --git a/deployment/gke-prod-manifests/gateway-backend-config.yaml b/deployment/gke-prod-manifests/gateway-backend-config.yaml index 3958d0b5..d390dc11 100644 --- a/deployment/gke-prod-manifests/gateway-backend-config.yaml +++ b/deployment/gke-prod-manifests/gateway-backend-config.yaml @@ -6,8 +6,8 @@ spec: healthCheck: timeoutSec: 3 type: HTTP - requestPath: /healthz - port: 8080 + requestPath: /healthcheck + port: 4000 customResponseHeaders: headers: - "Access-Control-Allow-Origin: https://www.codeparty.org" diff --git a/services/gateway/package.json b/services/gateway/package.json index 6fb1cebf..f469ceac 100644 --- a/services/gateway/package.json +++ b/services/gateway/package.json @@ -15,12 +15,14 @@ "dependencies": { "cors": "^2.8.5", "dotenv": "^16.3.1", + "express-healthcheck": "^0.1.0", "firebase-admin": "^11.10.1", "http-proxy-middleware": "^2.0.6", "morgan": "^1.10.0" }, "devDependencies": { "@types/cors": "^2.8.14", + "@types/express-healthcheck": "^0.1.2", "@types/morgan": "^1.9.6", "swagger-autogen": "^2.23.6", "ts-node-dev": "^2.0.0", diff --git a/services/gateway/src/app.ts b/services/gateway/src/app.ts index 8b19d5f6..49e80fcd 100644 --- a/services/gateway/src/app.ts +++ b/services/gateway/src/app.ts @@ -6,6 +6,7 @@ import { setupProxies } from "./proxy/proxy"; import {http_proxied_routes, wsCollaborationProxiedRoutes, wsMatchProxiedRoutes} from "./proxied_routes/proxied_routes"; import {frontendAddress} from "./proxied_routes/service_names"; import {createProxyMiddleware} from "http-proxy-middleware"; +import healthCheck from "express-healthcheck"; const httpApp : Express = express(); @@ -25,6 +26,9 @@ httpApp.use(cors(corsOptions)); wsMatchApp.use(cors(corsOptions)); wsCollaborationApp.use(cors(corsOptions)); +// Health check +httpApp.use('/healthcheck', healthCheck()); + /** * WARNING: Do not add body parsing middleware to the Gateway. * Otherwise, proxying POST requests with request body would not work. diff --git a/yarn.lock b/yarn.lock index 19c965c4..111b543b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3059,6 +3059,13 @@ dependencies: "@types/node" "*" +"@types/express-healthcheck@^0.1.2": + version "0.1.2" + resolved "https://registry.yarnpkg.com/@types/express-healthcheck/-/express-healthcheck-0.1.2.tgz#1f1aa8846d5e0fb9f71a9acad8ac2f1806bf6fd6" + integrity sha512-enSA1JuIErGJqfCCDmNAq6N8OIBhgdg+mBvHUOTrjy7zdrDEKJ4sJr97MoFZNIDh32bUII1F+uPmqgC9H8b4mQ== + dependencies: + "@types/express" "*" + "@types/express-serve-static-core@^4.17.33": version "4.17.39" resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.39.tgz#2107afc0a4b035e6cb00accac3bdf2d76ae408c8" @@ -6050,6 +6057,11 @@ exponential-backoff@^3.1.1: resolved "https://registry.yarnpkg.com/exponential-backoff/-/exponential-backoff-3.1.1.tgz#64ac7526fe341ab18a39016cd22c787d01e00bf6" integrity sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw== +express-healthcheck@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/express-healthcheck/-/express-healthcheck-0.1.0.tgz#cabec78129c4cb90cd7fb894dfae21b82e27cb07" + integrity sha512-FKQVgDo1FMSOYflEq4g6CvNk6stbpkuX0MWXmul8dSICuw/b+3JgoYOq/aiDcYid5k42jh/4HYLYC/M/qDBEuQ== + express-normalize-query-params-middleware@^0.5.0: version "0.5.1" resolved "https://registry.yarnpkg.com/express-normalize-query-params-middleware/-/express-normalize-query-params-middleware-0.5.1.tgz#dbe1e8139aecb234fb6adb5c0059c75db9733d2a"