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

volleyball

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

volleyball

🏐 Tiny HTTP logger for Express showing asynchronous requests and responses

  • 1.5.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
244
decreased by-59.8%
Maintainers
1
Weekly downloads
 
Created
Source

🏐 Volleyball

npm version Build Status Greenkeeper badge code style: prettier

Small Express HTTP logger for debugging asynchronous requests and responses

const app = require('express')()
const volleyball = require('volleyball')

app.use(volleyball)

Screenshot

Volleyball is a minimal Connect-style middleware function which logs incoming requests and outgoing responses as separate events. It optionally supports the debug module.

Motivation

Logging HTTP cycles can be approached in several ways, each with its own drawbacks:

  • Log only upon request. Drawback: we cannot log the corresponding response, which happens later (if at all).
  • Log only upon response, attaching the request. Drawback A: if the server never sends a response, e.g. due to a bug, the request will not be logged either. Drawback B: two temporally distinct events are conflated, misleadingly.
  • Log both upon request and response. Drawback: it is not necessarily clear which responses are for which requests.

Volleyball takes the last approach, and assigns randomly-generated ids to label request-response pairs. It is designed for student project development, teaching beginning programmers how HTTP servers and asynchronicity work. It may also be useful as a low-configuration debug tool.

Usage

volleyball

The volleyball module can be used directly as demonstrated in the first example. The module defaults to using process.stdout for output.

volleyball.custom(config)

A customized logging middleware can be generated by calling custom with a configuration object:

const logger = volleyball.custom({ debug: true }) // default namespace 'http'
// const logger = volleyball.custom({ debug: 'custom-namespace' })
// const logger = volleyball.custom({ debug: debugInstance })

app.use(logger)

The debug property logs using the debug module. It supports the following values:

valueresult
trueuses a new debug instance with a default namespace of 'http'
stringuses a new debug instance with a custom namespace
functionuses any function, such as a pre-generated debug instance. Note that the function will be called with colorized strings.

For more powerful, configurable, and compatible logging needs, check out:

Keywords

FAQs

Package last updated on 31 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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