Log HTTP requests and responses as ndjson (newline-delimited JSON). Version 3.1.0 is the latest stable release. It is designed to work well with bole and garnish for pretty-printing. Minimal dependencies and a focus on standard request/response properties. Use it to produce structured logs that can be piped to other ndjson-consuming tools.
npm install http-ndjsonNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create an HTTP server and log requests/responses as ndjson using the default callback (console.log).
Update your callback to accept the ndjson object directly (e.g., `console.log(msg)` instead of `console.log(msg1, msg2)`).
Always pass the correct byte length of the response body to the returned function (e.g., `setSize(Buffer.byteLength(body))`).
Use `require()` or configure your project to use CommonJS. Alternatively, use a dynamic import with a bundler that can handle CJS.
No action needed.
Use `const httpNdjson = require('http-ndjson')` without destructuring.Use dynamic import(): `import('http-ndjson').then(m => m.default)`, or change the project to CommonJS.Ensure you pass a callback function as the third argument: `const setSize = httpNdjson(req, res, console.log)`
No dependency data recorded yet.