Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fastify-healthcheck

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-healthcheck - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

8

CHANGELOG.md
# Change Log
## [2.2.0](https://github.com/smartiniOnGitHub/fastify-healthcheck/releases/tag/2.2.0) (2020-05-24)
Summary Changelog:
- Add a new plugin flag 'exposeUptime' (by default false, so disabled)
to add even Node.js process uptime in the reply, when enabled
- Updated requirements to Fastify '^2.8.0' (as dev dependency)
- Keep dependency on 'under-pressure' 3.x in this release
- Updated other dev dependencies
## [2.1.0](https://github.com/smartiniOnGitHub/fastify-healthcheck/releases/tag/2.1.0) (2019-05-08)

@@ -4,0 +12,0 @@ Summary Changelog:

2

example/example.js

@@ -25,3 +25,5 @@ /*

// healthcheckUrlAlwaysFail: true,
// exposeUptime: true,
// underPressureOptions: { } // no under-pressure specific options set here
exposeUptime: true // enable, as a sample
})

@@ -28,0 +30,0 @@

15

package.json
{
"name": "fastify-healthcheck",
"version": "2.1.0",
"version": "2.2.0",
"description": "Fastify Plugin to serve responses for health checks",

@@ -22,4 +22,7 @@ "main": "src/plugin",

"lint": "standard \"./*.js\" \"./src/**/*.js\" \"./test/**/*.test.js\" \"./example/**/*.js\"",
"test:unit": "tap -J test/*.test.js test/*/*.test.js",
"test:unit:debug": "tap -T --strict --node-arg=--inspect-brk test/*.test.js test/*/*.test.js",
"test:coverage": "npm run test:unit -- --cov --coverage-report=html",
"test:coverage:all": "npm run test:unit -- --cov",
"test:unit": "tap -J --comments --no-esm --strict test/*.test.js",
"test:unit:debug": "tap -T --node-arg=--inspect-brk --comments --no-esm --strict test/*.test.js",
"test:unit:dev": "tap -J --comments --no-esm --strict --watch test/*.test.js",
"test": "npm run lint && npm run test:unit"

@@ -31,6 +34,6 @@ },

"devDependencies": {
"fastify": "^2.1.0",
"fastify": "^2.8.0",
"simple-get": "^3.0.3",
"standard": "^12.0.1",
"tap": "^12.7.0"
"standard": "^14.3.4",
"tap": "^14.10.7"
},

@@ -37,0 +40,0 @@ "peerDependencies": {},

@@ -28,2 +28,3 @@ # fastify-healthcheck

- `healthcheckUrlAlwaysFail`, to always return failure responses (useful to test failure responses)
- `exposeUptime`, to return even Node.js process uptime (by default disabled)

@@ -30,0 +31,0 @@ Under the hood, the healthcheck status is determined by the

@@ -41,3 +41,3 @@ /*

}
console.log(`----------------`)
console.log('----------------')
}

@@ -44,0 +44,0 @@ if (res.statusCode === 200) {

@@ -18,2 +18,5 @@ /*

const payloadOK = { statusCode: 200, status: 'ok' }
const payloadKO = { statusCode: 500, status: 'ko' }
function fastifyHealthcheck (fastify, options, next) {

@@ -24,2 +27,3 @@ const {

healthcheckUrlAlwaysFail = false,
exposeUptime = false,
underPressureOptions = { }

@@ -31,2 +35,3 @@ } = options

ensureIsBoolean(healthcheckUrlAlwaysFail, 'healthcheckUrlAlwaysFail')
ensureIsBoolean(exposeUptime, 'exposeUptime')
ensureIsObject(underPressureOptions, 'underPressureOptions')

@@ -43,2 +48,5 @@

let healthcheckHandler = normalHandler
if (exposeUptime === true) {
healthcheckHandler = normalHandlerWithUptime
}
if (healthcheckUrlAlwaysFail !== null && healthcheckUrlAlwaysFail === true) {

@@ -60,9 +68,14 @@ healthcheckHandler = failHandler

function failHandler (req, reply) {
reply.code(500).send({ statusCode: 500, status: 'ko' })
reply.code(500).send(payloadKO)
}
function normalHandler (req, reply) {
reply.code(200).send({ statusCode: 200, status: 'ok' })
reply.code(200).send(payloadOK)
}
function normalHandlerWithUptime (req, reply) {
payloadOK.uptime = process.uptime()
reply.code(200).send(payloadOK)
}
function ensureIsString (arg, name) {

@@ -69,0 +82,0 @@ if (arg !== null && typeof arg !== 'string') {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc