โš  This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

๐ŸŒŒ Tiniest body parser in the universe. Built for modern Node.js

License

Notifications You must be signed in to change notification settings

tinyhttp/milliparsec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation






Version Coverage Github actions Downloads


Tiniest body parser in the universe. Built for modern Node.js.

Check out deno-libs/parsec for Deno port.

Features

  • ๐Ÿ›  JSON / raw / urlencoded / multipart support
  • ๐Ÿ“ฆ tiny package size (8KB dist size)
  • ๐Ÿ”ฅ no dependencies
  • โœจ tinyhttp and Express support
  • โšก 40% faster than body-parser and 20x faster than formidable

Install

# pnpm
pnpm i milliparsec

# bun
bun i milliparsec

Usage

Basic example

Use a middleware inside a server:

import { createServer } from 'node:http'
import { json } from 'milliparsec'

const server = createServer(async (req: ReqWithBody, res) => {
  await json()(req, res, (err) => void err && res.end(err))

  res.setHeader('Content-Type', 'application/json')

  res.end(JSON.stringify(req.body))
})

What is "parsec"?

The parsec is a unit of length used to measure large distances to astronomical objects outside the Solar System.

Sponsor this project

Contributors 8