Description
Modern asynchronous body parser for Node.js.
It puts all the data into req.body so you don't have to create a separate array for it.
Supports Node.js 13+ ESM, CJS.
Integrates with Express, Koa and native `http` module
parsec ๐ alternatives and similar modules
Based on the "Parsing" category.
Alternatively, view parsec ๐ alternatives based on common mentions on social networks and blogs.
-
markdown-it
Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed -
remark
markdown processor powered by plugins part of the @unifiedjs collective -
@parcel/css
An extremely fast CSS parser, transformer, bundler, and minifier written in Rust. -
nearley
๐๐๐ฒ Simple, fast, powerful parser toolkit for JavaScript. -
parse5
HTML parsing/serialization toolset for Node.js. WHATWG HTML Living Standard (aka HTML5)-compliant. -
fast-xml-parser
Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback. -
csv-parser
Streaming csv parser inspired by binary-csv that aims to be faster than everyone else -
google-libphonenumber
The up-to-date and reliable Google's libphonenumber package for node.js. -
xlsx-populate
Excel XLSX parser/generator written in JavaScript with Node.js and browser support, jQuery/d3-style method chaining, encryption, and a focus on keeping existing workbook features and styles in tact. -
json-mask
Tiny language and engine for selecting specific parts of a JS object, hiding the rest. -
Awesome phonenumber parser
Google's libphonenumber pre-compiled with the closure compiler -
strip-json-comments
Strip comments from JSON. Lets you use comments in your JSON files! -
binary-extract
Extract a value from a buffer of json without parsing the whole thing -
docx-to-pdf-on-AWS-Lambda
Microsoft Word doc/docx to PDF conversion on AWS Lambda using Node.js
Amplication: open-source Node.js backend code generator
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of parsec ๐ or a related project?
README
Tiniest body parser in the universe. Built for modern Node.js.
Check out deno-libs/parsec for Deno port.
Features
- โฉ built with
async
/await
- ๐ JSON / raw / urlencoded data support
- ๐ฆ tiny package size (728B)
- ๐ฅ no dependencies
- โก tinyhttp and Express support
Install
# pnpm
pnpm i milliparsec
# yarn
yarn add milliparsec
# npm
npm i milliparsec
Usage
Basic example
Use a middleware inside a server:
import { createServer } from 'http'
import { json } from 'milliparsec'
const server = createServer(async (req: ReqWithBody, res) => {
await json()(req, res, (err) => void err && console.log(err))
res.setHeader('Content-Type', 'application/json')
res.end(JSON.stringify(req.body))
})
Web frameworks integration
tinyhttp
import { App } from '@tinyhttp/app'
import { urlencoded } from 'milliparsec'
new App()
.use(urlencoded())
.post('/', (req, res) => void res.send(req.body))
.listen(3000, () => console.log(`Started on http://localhost:3000`))
API
raw(req, res, cb)
Minimal body parsing without any formatting.
text(req, res, cb)
Converts request body to string.
urlencoded(req, res, cb)
Parses request body using querystring.parse
.
json(req, res, cb)
Parses request body using JSON.parse
.
custom(fn)(req, res, cb)
Custom function for parsec
.
// curl -d "this text must be uppercased" localhost
await custom(
req,
(d) => d.toUpperCase(),
(err) => {}
)
res.end(req.body) // "THIS TEXT MUST BE UPPERCASED"
What is "parsec"?
The parsec is a unit of length used to measure large distances to astronomical objects outside the Solar System.