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

node-health-agent

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-health-agent - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

11

index.js

@@ -30,4 +30,11 @@ const os = require('os')

ws.on('message', (msg) => {
if (!events[msg]) return console.warn(`Event ${msg} not handled!\nYou can use the addEvent() method to attach an action to a specific event.`)
events[msg](msg, inspector)
let eventName
try {
msg = JSON.parse(msg)
eventName = msg.name
} catch (e) {
eventName = msg
}
if (!events[eventName]) return console.warn(`Event ${eventName} not handled!\nYou can use the addEvent() method to attach an action to a specific event.`)
events[eventName](msg, inspector)
})

@@ -34,0 +41,0 @@

2

package.json
{
"name": "node-health-agent",
"version": "0.3.0",
"version": "0.4.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -216,3 +216,30 @@ const WebSocket = require('ws')

})
it('should handle event as JSON object', (done) => {
wss = new WebSocket.Server({
port: 3000
})
wss.on('listening', () => {
agent = require('../index')({
appName: 'test',
serverUrl: 'ws://localhost:3000'
})
agent.addEvent('custom_event_json', (event) => {
expect(event.name).toEqual('custom_event_json')
expect(event.data.key).toEqual('value')
done()
})
agent.ws.on('open', () => {
expect(typeof agent.addEvent).toEqual('function')
wss.clients.forEach(ws => {
ws.send('{"name":"custom_event_json","data":{"key":"value"}}')
})
})
})
})
})
})
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