New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pm2/js-api

Package Overview
Dependencies
Maintainers
4
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pm2/js-api - npm Package Compare versions

Comparing version 0.5.46 to 0.5.47

src/realtime.js

2

package.json
{
"name": "@pm2/js-api",
"version": "0.5.46",
"version": "0.5.47",
"description": "PM2.io API Client for Javascript",

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

@@ -107,2 +107,28 @@ # PM2.io API Client for Javascript

#### Events available
| Event | Description |
|-------|-------------|
| mediator:blacklist | Used to broadcast updated process blacklisted |
| human:event | Events sent via pmx.emit() |
| process:exception | Issues from pm2 or apm |
| logs | Logs |
| status | Status sent by apm or pm2 |
| metric | Metric sent by apm/collectors |
| axm:transaction:outlier | Outlier for transaction tracing |
| process:event | Event from pm2 (restart...) |
| profiling | Profiling packet with profiling link |
| axm:scoped_action:stream | Stream from scoped action |
| axm:scoped_action:end | End of scoped action |
| axm:scoped_action:error | Error for a scoped action |
| pm2:scoped:end | End for pm2 scoped |
| pm2:scoped:stream | Stream from pm2 scoped |
| pm2:scoped:error | Error from pm2 scoped |
| trace-span | Span for distributed tracing |
| axm:transaction | Transaction for transaction tracing |
| trigger:pm2:result | Result from a pm2 action |
| trigger:action:success | Success from a custom action |
| trigger:action:failure | Error from a customer action |
| axm:reply | Reply from a custom action |
## Route definition

@@ -109,0 +135,0 @@

@@ -40,2 +40,14 @@

})
// https://github.com/EventEmitter2/EventEmitter2/issues/214
const self = this
const realtimeOn = this.realtime.on
this.realtime.on = function () {
self.editSocketFilters('push', arguments[0])
return realtimeOn.apply(self.realtime, arguments)
}
const realtimeOff = this.realtime.off
this.realtime.off = function () {
self.editSocketFilters('remove', arguments[0])
return realtimeOff.apply(self.realtime, arguments)
}
this.realtime.subscribe = this.subscribe.bind(this)

@@ -289,2 +301,21 @@ this.realtime.unsubscribe = this.unsubscribe.bind(this)

editSocketFilters (type, event) {
event = event.split(':')
const bucketPublicId = event[0]
const filter = event.slice(2).join(':')
const socket = this._websockets.find(socket => socket.bucketPublic === bucketPublicId)
if (!socket) return
if (type === 'push') {
socket.filters.push(filter)
} else {
socket.filters.splice(socket.filters.indexOf(filter), 1)
}
socket.send(JSON.stringify({
action: 'sub',
public_id: bucketPublicId,
filters: Array.from(new Set(socket.filters)) // avoid duplicates
}))
}
/**

@@ -315,2 +346,4 @@ * Subscribe to realtime from bucket

let socket = new WS(`${endpoint}/primus`, this.tokens.access_token)
socket.filters = []
socket.bucketPublic = bucket.public_id
socket.connected = false

@@ -330,4 +363,5 @@ socket.bucket = bucketId

socket.send(JSON.stringify({
action: 'active',
public_id: bucket.public_id
action: 'sub',
public_id: bucket.public_id,
filters: Array.from(new Set(socket.filters)) // avoid duplicates
}))

@@ -334,0 +368,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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