diff --git a/forge/auth.js b/forge/auth.js index 56c3bea..b423739 100644 --- a/forge/auth.js +++ b/forge/auth.js @@ -26,7 +26,7 @@ module.exports = fp(async function (app, opts, done) { } async function checkAuth (request, reply) { - if (request.url === '/metrics') { + if (request.url === '/metrics' || request.url === '/health') { return } try { diff --git a/forge/fileServer.js b/forge/fileServer.js index 74aca66..bb5d79b 100644 --- a/forge/fileServer.js +++ b/forge/fileServer.js @@ -89,6 +89,9 @@ module.exports = async (options = {}) => { // Routes await server.register(routes, { logLevel: server.config.logging.http }) + // Health status + await server.register(require('fastify-healthcheck')) + server.ready() return server diff --git a/package-lock.json b/package-lock.json index 2e3b360..f3f27bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@fastify/helmet": "^11.0.0", "@node-red/util": "^3.1.0", "fastify": "^4.21.0", + "fastify-healthcheck": "^4.4.0", "fastify-metrics": "^10.3.0", "fastify-plugin": "^4.5.1", "got": "^11.8.6", @@ -897,6 +898,15 @@ "helmet": "^7.0.0" } }, + "node_modules/@fastify/under-pressure": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@fastify/under-pressure/-/under-pressure-8.3.0.tgz", + "integrity": "sha512-ap1EePB9vHm8uQLM0nnaOeIMBLooNmAMTnccavBRwaXmu+acJFuSEQRVdMGRkW6viFDhdo5RGTcHzMBQyrucEA==", + "dependencies": { + "@fastify/error": "^3.0.0", + "fastify-plugin": "^4.0.0" + } + }, "node_modules/@gar/promisify": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz", @@ -3219,6 +3229,17 @@ "tiny-lru": "^11.0.1" } }, + "node_modules/fastify-healthcheck": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/fastify-healthcheck/-/fastify-healthcheck-4.4.0.tgz", + "integrity": "sha512-goP2YYBp+inqrEFixZDxsoxFN8h219ZOzCFv1sMpleaxwbo5CmoLrVzrja6vCMa1LNx6aEvOcGaqLX5Oev1q/A==", + "dependencies": { + "@fastify/under-pressure": "^8.2.0" + }, + "engines": { + "node": ">=14.15.0" + } + }, "node_modules/fastify-metrics": { "version": "10.3.0", "resolved": "https://registry.npmjs.org/fastify-metrics/-/fastify-metrics-10.3.0.tgz", @@ -7513,6 +7534,15 @@ "helmet": "^7.0.0" } }, + "@fastify/under-pressure": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/@fastify/under-pressure/-/under-pressure-8.3.0.tgz", + "integrity": "sha512-ap1EePB9vHm8uQLM0nnaOeIMBLooNmAMTnccavBRwaXmu+acJFuSEQRVdMGRkW6viFDhdo5RGTcHzMBQyrucEA==", + "requires": { + "@fastify/error": "^3.0.0", + "fastify-plugin": "^4.0.0" + } + }, "@gar/promisify": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz", @@ -9287,6 +9317,14 @@ "tiny-lru": "^11.0.1" } }, + "fastify-healthcheck": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/fastify-healthcheck/-/fastify-healthcheck-4.4.0.tgz", + "integrity": "sha512-goP2YYBp+inqrEFixZDxsoxFN8h219ZOzCFv1sMpleaxwbo5CmoLrVzrja6vCMa1LNx6aEvOcGaqLX5Oev1q/A==", + "requires": { + "@fastify/under-pressure": "^8.2.0" + } + }, "fastify-metrics": { "version": "10.3.0", "resolved": "https://registry.npmjs.org/fastify-metrics/-/fastify-metrics-10.3.0.tgz", diff --git a/package.json b/package.json index eda4ce7..ab64d96 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "fastify": "^4.21.0", "fastify-metrics": "^10.3.0", "fastify-plugin": "^4.5.1", + "fastify-healthcheck": "^4.4.0", "got": "^11.8.6", "pg": "^8.11.2", "pino": "^8.15.1",