Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tinyhttp/milliparsec
🌌 Tiniest body parser in the universe. Built for modern Node.js
https://github.com/tinyhttp/milliparsec
body-parser es6 es6-javascript express http javascript middleware node node-js nodejs tinyhttp typescript
Last synced: 6 days ago
JSON representation
🌌 Tiniest body parser in the universe. Built for modern Node.js
- Host: GitHub
- URL: https://github.com/tinyhttp/milliparsec
- Owner: tinyhttp
- License: mit
- Created: 2019-06-06T21:01:59.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-03T13:28:46.000Z (2 months ago)
- Last Synced: 2024-11-20T20:39:15.560Z (22 days ago)
- Topics: body-parser, es6, es6-javascript, express, http, javascript, middleware, node, node-js, nodejs, tinyhttp, typescript
- Language: TypeScript
- Homepage: https://npm.im/milliparsec
- Size: 6.46 MB
- Stars: 170
- Watchers: 3
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-made-by-indonesian - milliparsec - `Tiniest body parser in the universe. Built for modern Node.js` *by [tinyhttp](https://github.com/tinyhttp)* (M)
- made-in-indonesia - milliparsec - `Tiniest body parser in the universe. Built for modern Node.js` *by [tinyhttp](https://github.com/tinyhttp)* (M)
README
[![Version][v-badge-url]][npm-url] [![Coverage][cov-img]][cov-url] [![Github actions][gh-actions-img]][github-actions] [![Downloads][dl-badge-url]][npm-url]
Tiniest body parser in the universe. Built for modern Node.js.
Check out [deno-libs/parsec](https://github.com/deno-libs/parsec) for Deno port.
## Features
- 🛠JSON / raw / urlencoded / multipart support
- 📦 tiny package size (8KB dist size)
- 🔥 no dependencies
- ✨ [tinyhttp](https://github.com/tinyhttp/tinyhttp) and Express support
- âš¡ 30% faster than body-parser## Install
```sh
# pnpm
pnpm i milliparsec# bun
bun i milliparsec
```## Usage
### Basic example
Use a middleware inside a server:
```js
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.
[v-badge-url]: https://img.shields.io/npm/v/milliparsec.svg?style=for-the-badge&color=25608B&logo=npm&label=
[npm-url]: https://www.npmjs.com/package/milliparsec
[dl-badge-url]: https://img.shields.io/npm/dt/milliparsec?style=for-the-badge&color=25608B
[github-actions]: https://github.com/talentlessguy/milliparsec/actions
[gh-actions-img]: https://img.shields.io/github/actions/workflow/status/tinyhttp/milliparsec/main.yml?branch=master&style=for-the-badge&color=25608B&label=&logo=github
[cov-img]: https://img.shields.io/coveralls/github/tinyhttp/milliparsec?style=for-the-badge&color=25608B
[cov-url]: https://coveralls.io/github/tinyhttp/milliparsec