Socket
Socket
Sign inDemoInstall

@godaddy/terminus

Package Overview
Dependencies
Maintainers
9
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@godaddy/terminus - npm Package Compare versions

Comparing version 4.1.2 to 4.2.0

19

lib/terminus.js

@@ -19,3 +19,3 @@ 'use strict'

async function sendSuccess (res, options) {
const { info } = options
const { info, verbatim } = options

@@ -25,7 +25,12 @@ res.statusCode = 200

if (info) {
return res.end(JSON.stringify({
status: 'ok',
info: info,
details: info
}))
return res.end(
JSON.stringify(
Object.assign(
{
status: 'ok'
},
verbatim ? info : { info, details: info }
)
)
)
}

@@ -76,3 +81,3 @@ res.end(SUCCESS_RESPONSE)

}
return sendSuccess(res, { info })
return sendSuccess(res, { info, verbatim: healthChecks.verbatim })
} else {

@@ -79,0 +84,0 @@ listener(req, res)

@@ -84,2 +84,30 @@ 'use strict'

it('includes verbatim on resolve', async () => {
let onHealthCheckRan = false
createTerminus(server, {
healthChecks: {
'/health': () => {
onHealthCheckRan = true
return Promise.resolve({
version: '1.0.0'
})
},
verbatim: true
}
})
server.listen(8000)
const res = await fetch('http://localhost:8000/health')
expect(res.status).to.eql(200)
expect(res.headers.has('Content-Type')).to.eql(true)
expect(res.headers.get('Content-Type')).to.eql('application/json')
expect(onHealthCheckRan).to.eql(true)
const json = await res.json()
expect(json).to.deep.eql({
status: 'ok',
version: '1.0.0'
})
})
it('returns 503 on reject', async () => {

@@ -238,3 +266,3 @@ let onHealthCheckRan = false

it('runs onSignal when getting SIGUSR2 signal', () => {
let result = spawnSync('node', ['lib/standalone-tests/terminus.onsigusr2.js'])
const result = spawnSync('node', ['lib/standalone-tests/terminus.onsigusr2.js'])
expect(result.stdout.toString().trim()).to.eql('on-sigusr2-runs')

@@ -241,0 +269,0 @@ })

{
"name": "@godaddy/terminus",
"version": "4.1.2",
"version": "4.2.0",
"description": "",

@@ -37,3 +37,3 @@ "main": "index.js",

"semantic-release": "^15.5.1",
"standard": "^12.0.0",
"standard": "^14.0.0",
"supertest": "^4.0.0",

@@ -40,0 +40,0 @@ "travis-deploy-once": "^5.0.1",

@@ -37,6 +37,6 @@

function healthcheck () {
function healthCheck () {
return Promise.resolve(
// optionally include a resolve value to be included as
// info in the healthcheck response
// info in the health check response
)

@@ -56,5 +56,6 @@ }

const options = {
// healthcheck options
// health check options
healthChecks: {
'/healthcheck': healthcheck // a function returning a promise indicating service health
'/healthcheck': healthCheck // a function returning a promise indicating service health,
verbatim: true // [optional = false] use object returned from /healthcheck verbatim in response
},

@@ -91,3 +92,3 @@

return Promise.all([
// all your healthchecks goes here
// all your health checks goes here
].map(p => p.catch((error) => {

@@ -94,0 +95,0 @@ // silently collecting all the errors

@@ -7,3 +7,3 @@ declare module "@godaddy/terminus" {

constructor(message: string, causes: any);
public causes: string;
public causes: any;
}

@@ -21,2 +21,3 @@

onSignal?: () => Promise<any>;
onSendFailureDuringShutdown?: () => Promise<any>;
onShutdown?: () => Promise<any>;

@@ -33,3 +34,2 @@ beforeShutdown?: () => Promise<any>;

export const createTerminus: Terminus;
}
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