JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 119512
  • Score
    100M100P100Q159545F
  • License MIT

Get stats on your Node.js HTTP server requests

Package Exports

  • request-stats

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (request-stats) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

request-stats

Build Status

Get stats on your Node.js HTTP server requests.

Emits an stats event for each request with a single object as its first argument, containing the following properties:

  • read: Number of bytes sent by the client
  • written: Number of bytes sent back to the client
  • method: The HTTP method used by the client
  • status: The HTTP status code returned to the client

Installation

npm install request-stats

Usage

var requestStats = require('request-stats');

http.createServer(function (req, res) {
  requestStats(req, res).on('stats', function (stats) {
    console.log(stats); // { read: 42, written: 123, method: 'PUT', status: 200 }
  });
});

Can also be used as Connect/Express middleware:

app.use(requestStats.middleware());

requestStats.on('stats', function (stats) {
  console.log(stats); // { read: 42, written: 123, method: 'PUT', status: 200 }
});

Acknowledgement

Thanks to mafintosh for coming up with the initial concept and pointing me in the right direction.

License

MIT