{"_id":"lum_request-stats","_rev":"2-dfa0ced47370e4930fce156a8ef19928","name":"lum_request-stats","dist-tags":{"latest":"3.2.0"},"versions":{"3.1.0":{"name":"lum_request-stats","version":"3.1.0","description":"Get stats on your Node.js HTTP server requests","main":"index.js","scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git://github.com/watson/request-stats.git"},"keywords":["stats","statistics","http","https","middleware","connect","express","analytics"],"author":{"name":"Thomas Watson Steen","email":"w@tson.dk"},"license":"MIT","bugs":{"url":"https://github.com/watson/request-stats/issues"},"homepage":"https://github.com/watson/request-stats","dependencies":{"http-headers":"^3.0.1","once":"^1.4.0"},"devDependencies":{"https-pem":"^1.0.4","keep-alive-agent":"^0.0.1","standard":"^8.6.0","tape":"^4.6.3"},"engines":{"node":">=0.12"},"coordinates":[55.6811129,12.564524],"gitHead":"3b5f23ad668ac66e8168053e55cf5a105446b398","_id":"lum_request-stats@3.1.0","_nodeVersion":"12.18.3","_npmVersion":"6.14.6","dist":{"integrity":"sha512-RUM8TCtmYZgvOt1wMfP+A8QY11RJvBK9FVJ9GNYvbThBGui4rAglV4wcnY2LPz51EF4R5yeq+BfnWVZRz70tdA==","shasum":"5de645f9e01d6c5ecc857cb34f9281f5f1185528","tarball":"https://registry.npmjs.org/lum_request-stats/-/lum_request-stats-3.1.0.tgz","fileCount":9,"unpackedSize":21096,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXNsKCRA9TVsSAnZWagAAT1wP/2V40qU47b8AgmD1fjQ8\nS9f29dn/r75+ntzc2F7zyHosMNShqxv2ldfq92i5tiD7StHDxO3Orz4pqhRf\nN4DwL/90PxnX+E2P8Xe5qh7zYKlKvZQwPgXg0ifcSYE/Sv8ecAE84JZN5wm7\nX8GAgxQF56b+ZMqlMsZyoTSGlT7twHsQK2zhKaqEQCqDV7rDJ7yp4mpElTft\nCt+4vmTWdqgB5lavBTavXo1Duo27ph3yF6NpNm/vMtBc39mIvhq8Kvz5/7Nj\noGdzqFENl0lLkcxreRceWnXTRiD7jQc4arltVTZbYDQ11zEZOLWnGV4w538i\nL5mxK+UjVTJb/xSIX+at33HsNnEXePuLJb+hx8lj/HQ4J8rPaZoL8JgCIkrf\nyeb5brkIWBqqCLbzAT4k95VZaWZ0Q0p0Ou9tt16aqeVomqVea6J3wAfOgB16\n71HiG7FU9ZBRfHqWmy8qku74yhFuFfKrK8Q/hH7TOLhzML5mrOFij2R/vuX+\nArWceSZpuKdsbUG4lqEd93HSoDPye0v1TB7/QpwqHJRQaUgl22iDTYx5mEJr\nx7yg/F5aU/wlZ99Lwk/7k88H+3YCSle526v+qIu3e9K6T8TKzuGU7WgJMNZv\nw0ZYz+HHgJiLront87bS6F982q7Kpp67hJ2yCGK4BcYT5Pb4ED+h+BATKBmE\nKRv3\r\n=wFNN\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCChv6uYA+t0usI2yF9/YSGSUidGas/k43MnT79R5ULagIgJKhOcKW/6h0AXIKG3LTAWuKcW+xdNHMz6QIp+rCRZJw="}]},"_npmUser":{"name":"luminati.io","email":"npm@luminati.io"},"directories":{},"maintainers":[{"name":"luminati.io","email":"npm@luminati.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lum_request-stats_3.1.0_1616698121623_0.34792732726951003"},"_hasShrinkwrap":false},"3.2.0":{"name":"lum_request-stats","version":"3.2.0","description":"Get stats on your Node.js HTTP server requests","main":"index.js","scripts":{"test":"standard && tape test.js"},"repository":{"type":"git","url":"git://github.com/watson/request-stats.git"},"keywords":["stats","statistics","http","https","middleware","connect","express","analytics"],"author":{"name":"Thomas Watson Steen","email":"w@tson.dk"},"license":"MIT","bugs":{"url":"https://github.com/watson/request-stats/issues"},"homepage":"https://github.com/watson/request-stats","dependencies":{"http-headers":"^3.0.1","once":"^1.4.0"},"devDependencies":{"https-pem":"^1.0.4","keep-alive-agent":"^0.0.1","standard":"^8.6.0","tape":"^4.6.3"},"engines":{"node":">=0.12"},"coordinates":[55.6811129,12.564524],"gitHead":"4373d2d5313a834e59753ebcd9f649349b1349cd","_id":"lum_request-stats@3.2.0","_nodeVersion":"12.18.3","_npmVersion":"6.14.6","dist":{"integrity":"sha512-VmTzbVS+DoNIXr8kitj1NHFe2HabNHeBLRQ4grA0RSEmnTPNcLR1eU85/N8o4ceksJv/LVouvkdiTPQ0+QEXpw==","shasum":"d92fc34ab10bd17e151d6f195d0b105153290069","tarball":"https://registry.npmjs.org/lum_request-stats/-/lum_request-stats-3.2.0.tgz","fileCount":9,"unpackedSize":21090,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXN0RCRA9TVsSAnZWagAAIjgP/RRrc4GvZ0trlWylrowD\nbZjUExPrwikpnZmimqYdBcoiuFFJeqJ+N5ix340Oqcd3Du+56ilMAPd+pp8i\nAJrciofbIhn2AuaNSiWb3pW4tX9hiP0h+VN7Cc5J6dJdGvf0JOjJN8DJpz5j\n67db8zyvpcpR0Gg8QP3LPULnf8NLmrT+0B43HMKjrn9iWTnNTTvqWZvbM7qX\nK7gf7ktJSMiHLUr0gdbGtzV+bOC1AhgbH+VPWfPLleCmQKQjHnRcn3pmUA4T\n6MEpCqeRl31aOs6a9an/kSo0lVxI38OeVQFMaS9yDq8cBLwaDUNQnGFrAqOJ\n69pcFCegGY4eJ+Zdda6G69Qy1fU2piSO31WAPPnuRp4IDV19UaA/CymiXegx\nTsW6GISqgYoafVT+Gikq7B43xvYxux0E5SVdnf5kk8iyvpbB+/MtbkBdldS6\nVQVDZdcL49ukkknlqlDdmOMxJGxq9y1JjndqvaQCD5qnWKS2YDJ54MlhDfsP\nNK6GqPuW1MTpma+Wd/ISs7vHipSYXzUnC0WeYy6hbPpNIgBWpJ2I+7RZ5nOm\nWMVE7C/c1pU1wLnsDRnHcXu72hpKhUPYom1amNjdlHSee2lrblEJHlxvn4r5\niSjawdG62wz0ph6HMIdHU8qLn6PWp4bNR6sDtkKaiK7AborjJeuikgjpOGEj\n9I5n\r\n=L9iD\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDzZMvvyf5dHNKfDgNjVqVNeD9HgQskjlGu8AHU2bm8sQIgGR8Ne6oK8bfXAtlyWPfXrHoeVuBapwW+asOcQP6cQRc="}]},"_npmUser":{"name":"luminati.io","email":"npm@luminati.io"},"directories":{},"maintainers":[{"name":"luminati.io","email":"npm@luminati.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lum_request-stats_3.2.0_1616698641573_0.7787037852585339"},"_hasShrinkwrap":false}},"time":{"created":"2021-03-25T18:48:41.623Z","3.1.0":"2021-03-25T18:48:41.787Z","modified":"2022-05-08T13:10:08.705Z","3.2.0":"2021-03-25T18:57:21.699Z"},"maintainers":[{"name":"luminati.io","email":"npm@luminati.io"}],"description":"Get stats on your Node.js HTTP server requests","homepage":"https://github.com/watson/request-stats","keywords":["stats","statistics","http","https","middleware","connect","express","analytics"],"repository":{"type":"git","url":"git://github.com/watson/request-stats.git"},"author":{"name":"Thomas Watson Steen","email":"w@tson.dk"},"bugs":{"url":"https://github.com/watson/request-stats/issues"},"license":"MIT","readme":"# request-stats\n\n[![Build status](https://travis-ci.org/watson/request-stats.svg?branch=master)](https://travis-ci.org/watson/request-stats)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)\n\nGet stats on your Node.js HTTP server requests.\n\nEmits two events:\n\n- `request` when ever a request starts: Passes a [Request object](#request-object) that can later be used to [query for the progress](#progress) of a long running request\n- `complete` when ever a request completes: Passes a [stats object](#oncomplete-callback) containing the overall stats for the entire HTTP request\n\n## Installation\n\n```\nnpm install request-stats --save\n```\n\n## Example usage\n\nGet stats for each completed HTTP request:\n\n```javascript\nvar requestStats = require('request-stats')\nvar server = http.createServer(...)\n\nrequestStats(server, function (stats) {\n  // this function will be called every time a request to the server completes\n  console.log(stats)\n})\n```\n\nGet periodic stats for long running requests:\n\n```javascript\nvar server = http.createServer(...)\n\nvar stats = requestStats(server)\n\nstats.on('request', function (req) {\n  // evey second, print stats\n  var interval = setInterval(function () {\n    var progress = req.progress()\n    console.log(progress)\n    if (progress.completed) clearInterval(interval)\n  }, 1000)\n})\n```\n\n## API\n\n### Constructor\n\n#### `requestStats(server[, callback])`\n\nAttach request-stats to a HTTP server.\n\nInitialize request-stats with an instance a HTTP server. Returns a\nStatsEmitter object. Optionally provide a callback which will be called\nfor each completed HTTP request with a stats object (see stats object\ndetails below).\n\nIf no callback is provided, you can later attach a listener on the\n\"complete\" event.\n\n#### `requestStats(req, res[, callback])`\n\nAttach request-stats to a single HTTP request.\n\nInitialize request-stats with an instance a HTTP request and response.\nReturns a StatsEmitter object. Optionally provide a callback which will\nbe called with a stats object when the HTTP request completes (see stats\nobject details below).\n\nIf no callback is provided, you can later attach a listener on the\n\"complete\" event.\n\n### StatsEmitter object\n\n#### `.on('complete', callback)`\n\nCalls the callback function with a stats object when a HTTP request\ncompletes:\n\n```javascript\n{\n  ok: true,           // `true` if the connection was closed correctly and `false` otherwise\n  time: 0,            // The milliseconds it took to serve the request\n  req: {\n    bytes: 0,         // Number of bytes sent by the client\n    headers: { ... }, // The headers sent by the client\n    method: 'POST',   // The HTTP method used by the client\n    path: '...',      // The path part of the request URL\n    ip: '...',        // The remote ip\n    raw: [Object]     // The original `http.IncomingMessage` object\n  },\n  res: {\n    bytes: 0,         // Number of bytes sent back to the client\n    headers: { ... }, // The headers sent back to the client\n    status: 200,      // The HTTP status code returned to the client\n    raw: [Object]     // The original `http.ServerResponse` object\n  }\n}\n```\n\n#### `.on('request', callback)`\n\nCalls the callback function with a special [Request\nobject](#request-object) when a HTTP request is made to the server.\n\n### Request object\n\nThe Request object should not be confused with the Node.js\n[http.IncomingMessage](http://nodejs.org/api/http.html#http_http_incomingmessage)\nobject. The request-stats Request object provides only a single\nbut powerfull function:\n\n#### `.progress()`\n\nReturns a progress object if called while a HTTP request is in progress.\nIf called multiple times, the returned progress object will contain the\ndelta of the previous call to `.progress()`.\n\n```javascript\n{\n  completed: false, // `false` if the request is still in progress\n  time: 0,          // The total time the reuqest have been in progress\n  timeDelta: 0,     // The time since previous call to .progress()\n  req: {\n    bytes: 0,       // Total bytes received\n    bytesDelta: 0,  // Bytes received since previous call to .progress()\n    speed: 0,       // Bytes per second calculated since previous call to .progress()\n    bytesLeft: 0,   // If the request contains a Content-Size header\n    timeLeft: 0     // If the request contains a Content-Size header\n  },\n  res: {\n    bytes: 0,       // Total bytes send back to the client\n    bytesDelta: 0,  // Bytes sent back to the client since previous call to .progress()\n    speed: 0        // Bytes per second calculated since previous call to .progress()\n  }\n}\n```\n\n## Acknowledgement\n\nThanks to [mafintosh](https://github.com/mafintosh) for coming up with\nthe initial concept and pointing me in the right direction.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}