{"name":"http-ndjson","version":"2.3.3","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","is-incoming-message":"^1.0.0","is-server-response":"^1.0.0","ndjson":"^1.4.1","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":"a7a0dfb185279620442b12df23e6a85aa32b3100","bugs":{"url":"https://github.com/yoshuawuyts/http-ndjson/issues"},"homepage":"https://github.com/yoshuawuyts/http-ndjson#readme","_id":"http-ndjson@2.3.3","_shasum":"05f03a282edac2d15c95c3b71cf0b222d8a15640","_from":".","_npmVersion":"2.14.5","_nodeVersion":"4.0.0","_npmUser":{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"},"dist":{"shasum":"05f03a282edac2d15c95c3b71cf0b222d8a15640","tarball":"http://registry-npm.ywwl.com/http-ndjson/download/http-ndjson-2.3.3.tgz","integrity":"sha512-HDSOMMmqXRQ75q1uPmJJLhMUmzzr+vxVwTwUhwiwim++9GPDncIgXcnawB+hgs72PMJD9vsEAYOJcEai6SAgrQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAo2L7xE+wmhoMAj8C4qY6wbkeb9G0a4aGKUVGeXdSIGAiEAyeK1/484XqEsdZjKQL2ffbqjkzznbueFmeDDD2cGJrM="}],"size":3270,"noattachment":false,"key":"/http-ndjson/-/http-ndjson-2.3.3.tgz"},"maintainers":[{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"}],"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":1445954871310,"_cnpm_publish_time":1445954871310,"dist-tags":{"latest":"3.1.0"}}