{"name":"http-ndjson","version":"3.0.0","description":"Log http requests as ndjson","main":"index.js","scripts":{"deps":"dependency-check . && dependency-check . --extra --no-dev","test":"standard && npm run deps && NODE_ENV=test node test","test:cov":"standard && npm run deps && NODE_ENV=test istanbul cover test.js"},"repository":{"type":"git","url":"git+https://github.com/yoshuawuyts/http-ndjson.git"},"keywords":["http","log","logger","ndjson","standard","request","response","server","development","production","modular","tiny","bole","bistre","garnish"],"license":"MIT","dependencies":{"end-of-stream":"^1.1.0","xtend":"^4.0.0"},"devDependencies":{"dependency-check":"^2.5.0","get-server-port":"^1.0.0","istanbul":"^0.3.19","standard":"^5.1.1","tape":"^4.2.0"},"files":["LICENSE","index.js","README.md"],"gitHead":"3ffbb40c48984c84405343c5ab364a1edc9b7738","bugs":{"url":"https://github.com/yoshuawuyts/http-ndjson/issues"},"homepage":"https://github.com/yoshuawuyts/http-ndjson#readme","_id":"http-ndjson@3.0.0","_shasum":"d21654c0b770417275528b900af589283f2d07fb","_from":".","_npmVersion":"3.5.2","_nodeVersion":"5.0.0","_npmUser":{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"},"dist":{"shasum":"d21654c0b770417275528b900af589283f2d07fb","tarball":"http://registry-npm.ywwl.com/http-ndjson/download/http-ndjson-3.0.0.tgz","integrity":"sha512-/XjaNI8QYk/J2YhzFuoBEwmdAkk8sjZ4ZbyhIvmZMMIpT+vuxZsrUT8J7sAu8Wb44tXw+YsBzddP1Mg4tBta2g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICp6sXnAyrBO5in835/I/20hU9r/haF69Bcwdtea2+xNAiEA1EBtYoqxQjrpAIzqLLQfsovkWGYNeAusGgf9t40G1OI="}],"size":2915,"noattachment":false,"key":"/http-ndjson/-/http-ndjson-3.0.0.tgz"},"maintainers":[{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/http-ndjson-3.0.0.tgz_1457066308651_0.4821360839996487"},"directories":{},"readme":"# http-ndjson\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![Downloads][downloads-image]][downloads-url]\n[![js-standard-style][standard-image]][standard-url]\n\nLog http requests as ndjson. Works pretty well with `bole`, so you should\nprobably use it with that. That is my recommendation.\n\n## Installation\n```sh\n$ npm install http-ndjson\n```\n\n## Usage\n```js\nconst httpNdjson = require('http-ndjson')\nconst http = require('http')\n\nhttp.createServer(function (req, res) {\n  const setSize = httpNdjson(req, res, console.log)\n  const myCoolResponse = 'chickens'\n  setSize(myCoolResponse.length)\n  res.end(myCoolResponse)\n}).listen()\n```\n```js\n{ name: 'http', method: 'GET', message: 'request', url: '/' }\n{ name: 'http', method: 'GET', message: 'response', url: '/', statusCode: 200, elapsed: '5ms' }\n```\n\n## Log custom properties\n`http-ndjson` logs a sensible set of standard properties, but sometimes there's\na need to dive in and log more. An optional third argument can be added with\ncustom fields that will be logged on either `request` or `response`.\n```js\nconst httpNdjson = require('http-ndjson')\nconst http = require('http')\n\nhttp.createServer(function (req, res) {\n  const opts = { req: { requestId: req.headers['requestId'] } }\n  httpNdjson(req, res, opts, console.log)\n  res.end()\n}).listen()\n```\n\nIf `opts.req` or `opts.res` is a function, it will be called and its return value will be used to set custom fields.\n\n## Forward headers\nDetermining the origin of a request can be hard when using reverse-proxies.\nIt's not too uncommon for users to mask their IP by providing an\n`x-forwarded-for` header. `http-ndjson` makes no assumptions about forwarding\nheaders and logs all properties instead. The following headers are logged:\n- __x-forwarded-for:__ standardized reverse proxy header ([rfc7239][7239])\n- __x-real-ip:__ non-standard reverse proxy header\n- __http-client-ip:__ non-standard reverse proxy header\n\n## API\n### readStream = httpNdjson(req, res, opts?, cb)\nCreate an http logger. Returns a write stream. Opts can contain the following\nvalues:\n- __req:__ an object with values that will be logged on `request`\n- __res:__ an object with values that will be logged on `response`\n- __opts:__ set options\n- __cb:__ handle the returned message\n\n## See Also\n- [bole](https://github.com/rvagg/bole)\n- [garnish](https://github.com/mattdesl/garnish)\n- [ndjson](https://github.com/maxogden/ndjson)\n\n## License\n[MIT](https://tldrlegal.com/license/mit-license)\n\n[npm-image]: https://img.shields.io/npm/v/http-ndjson.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/http-ndjson\n[travis-image]: https://img.shields.io/travis/yoshuawuyts/http-ndjson/master.svg?style=flat-square\n[travis-url]: https://travis-ci.org/yoshuawuyts/http-ndjson\n[codecov-image]: https://img.shields.io/codecov/c/github/yoshuawuyts/http-ndjson/master.svg?style=flat-square\n[codecov-url]: https://codecov.io/github/yoshuawuyts/http-ndjson\n[downloads-image]: http://img.shields.io/npm/dm/http-ndjson.svg?style=flat-square\n[downloads-url]: https://npmjs.org/package/http-ndjson\n[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[standard-url]: https://github.com/feross/standard\n[7239]: https://tools.ietf.org/html/rfc7239\n","publish_time":1457066309808,"_cnpm_publish_time":1457066309808,"dist-tags":{"latest":"3.1.0"}}