Milliparsec is a minimalistic and performant HTTP body parser for modern Node.js environments, currently at version 5.1.1. It provides middleware for parsing JSON, raw, URL-encoded, and multipart form data, making it compatible with frameworks like tinyhttp and Express. The library boasts a tiny package size (under 8KB) and zero dependencies, setting it apart from more heavy-weight alternatives like `body-parser` and `formidable`, offering significantly faster parsing speeds (approximately 15% faster than `body-parser` and 4x faster than `formidable`). It receives active development, with several minor and patch releases in quick succession, indicating a steady release cadence for bug fixes and feature enhancements, such as the recently added `type` and `reviver` options for JSON parsing in v5.1.0.
npm install milliparsecVerified import paths — ran on the pinned version, not inferred.
Demonstrates setting up an HTTP server with Node.js and `milliparsec` to parse a JSON request body using the `json` middleware. It includes basic error handling and type annotations.
Upgrade your Node.js runtime to version 18.13+, 19.20+, or 20+.
Review any custom parsers you have implemented with `milliparsec` to ensure compatibility with buffer-based data handling, adjusting logic as needed.
Migrate your codebase to use ES Module `import` syntax (`import { json } from 'milliparsec'`) for better compatibility and future-proofing.Always use `await` when invoking a `milliparsec` middleware function (e.g., `await json()(req, res, callback)`).
If encountering payload size errors, check the middleware options (e.g., `limit` option for JSON/text parsers) and increase them if necessary, or ensure client-side requests conform to the server's limits.
Convert your module to ES Modules by setting `"type": "module"` in `package.json` or by renaming files to `.mjs`, and use `import { json } from 'milliparsec'`.Ensure the middleware call is `await`ed and the callback for error handling is provided and processed: `await json()(req, res, (err) => { /* handle err */ });`Ensure the client sends correctly formatted JSON. On the server side, implement robust error handling within the middleware callback to gracefully respond to invalid input.
Configure the `limit` option when initializing the parser (e.g., `json({ limit: '10mb' })`) to allow larger payloads, or instruct clients to send smaller requests.No dependency data recorded yet.