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

lws-request-monitor

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lws-request-monitor - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

32

index.js

@@ -14,10 +14,8 @@ module.exports = MiddlewareBase => class RequestMonitor extends MiddlewareBase {

}
if (ctx.request.rawBody) reqInfo.data = ctx.request.rawBody
const incomingBuffer = ctx.req._readableState.buffer
if (!reqInfo.data && incomingBuffer.head && incomingBuffer.head.data.length) {
reqInfo.data = '__INCOMING__'
reqInfo.data[util.inspect.custom] = function (depth, options) {
const byteSize = require('byte-size')
const size = byteSize(incomingBuffer.head.data.length)
return options.stylize(`[ incoming data (${size} so far) ]`, 'special')
if (ctx.request.rawBody) {
reqInfo.body = ctx.request.body
} else {
const incomingBuffer = ctx.req._readableState.buffer
if (incomingBuffer.head && incomingBuffer.head.data.length) {
reqInfo.bodyHead = incomingBuffer.head.data.toString('utf8', 0, 1000)
}

@@ -36,8 +34,18 @@ }

if (headers) resInfo.headers = headers
if (ctx.body) resInfo.data = ctx.body
if (ctx.body) resInfo.body = ctx.body
const stream = require('stream')
if (resInfo.data instanceof stream.Readable) {
resInfo.data[util.inspect.custom] = function (depth, options) {
return options.stylize(`[ Readable Stream: ${resInfo.data.path} ]`, 'special')
if (resInfo.body instanceof stream.Readable) {
if (/text\/event-stream/.test(ctx.response.type)) {
resInfo.body[util.inspect.custom] = function (depth, options) {
return options.stylize('[ SSE event-stream ]', 'special')
}
} else if (ctx.body.path) {
resInfo.body[util.inspect.custom] = function (depth, options) {
return options.stylize(`[ ReadStream: ${ctx.body.path} ]`, 'special')
}
} else {
resInfo.body[util.inspect.custom] = function (depth, options) {
return options.stylize(`[ Readable Stream ]`, 'special')
}
}

@@ -44,0 +52,0 @@ }

{
"name": "lws-request-monitor",
"author": "Lloyd Brookes <75pound@gmail.com>",
"version": "0.1.1",
"version": "0.1.2",
"description": "Verbose request logging middleware for lws",

@@ -6,0 +6,0 @@ "repository": "https://github.com/lwsjs/request-monitor.git",

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