All Projects → tinyhttp → milliparsec

tinyhttp / milliparsec

Licence: MIT license
🌌 Tiniest body parser in the universe. Built for modern Node.js

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to milliparsec

discord-clock
A simple clock script for your bot to show what time it is in your server | Discord.js v13 ready!
Stars: ✭ 29 (-75%)
Mutual labels:  node-js
free-node.js-learning-resources
A curated list of free resources to learn node.js
Stars: ✭ 70 (-39.66%)
Mutual labels:  node-js
influx-crypto-watcher
Server that let you monitor many cryptocurrencies and store the OHLC data in InfluxDB (visualisation with grafana)
Stars: ✭ 49 (-57.76%)
Mutual labels:  node-js
napi-thread-safe-callback
C++ utility class to perform callbacks into JavaScript from any thread
Stars: ✭ 62 (-46.55%)
Mutual labels:  node-js
vayder
Easy and concise validations for Express routes
Stars: ✭ 26 (-77.59%)
Mutual labels:  node-js
orkid-node
Reliable and modern Redis Streams based task queue for Node.js 🤖
Stars: ✭ 61 (-47.41%)
Mutual labels:  node-js
karachi
Repository for organizing the karachi nodeschools events
Stars: ✭ 21 (-81.9%)
Mutual labels:  node-js
BotBlock.org
BotBlock - The List of Discord Bot Lists and Services
Stars: ✭ 29 (-75%)
Mutual labels:  node-js
twitter-like-bot
This app allows you to automate Twitter liking for specific keywords, hashtags, or even full sentences. The bot uses streaming API which means that everything happens in real time.
Stars: ✭ 30 (-74.14%)
Mutual labels:  node-js
babyfoot
Simple CQRS/ES Node+Express+TypeScript REST API
Stars: ✭ 14 (-87.93%)
Mutual labels:  node-js
steam-mass-comment-bot
💬 Comment with a few clicks under a ton of steam profiles & groups!
Stars: ✭ 16 (-86.21%)
Mutual labels:  node-js
zuly
🤖 | Hi, I'm zuly, a brazilian bot! Focused on animes!
Stars: ✭ 45 (-61.21%)
Mutual labels:  node-js
chainDB
A noSQL database based on blockchain technology
Stars: ✭ 13 (-88.79%)
Mutual labels:  node-js
mybatis-mapper
generate SQL statements from the MyBatis3 Mapper XML file in Node.js
Stars: ✭ 64 (-44.83%)
Mutual labels:  node-js
moneywave-nodejs
A client library for moneywave API
Stars: ✭ 16 (-86.21%)
Mutual labels:  node-js
node two captcha
Node package for 2Captcha (Captcha Solver as a Service)
Stars: ✭ 43 (-62.93%)
Mutual labels:  node-js
fridaybot
Slack bot for https://spb-frontend.slack.com
Stars: ✭ 29 (-75%)
Mutual labels:  node-js
node-typescript-starter
REST API using Node with typescript, KOA framework. TypeORM for SQL. Middlewares JWT (auth), CORS, Winston Logger, Error, Response
Stars: ✭ 19 (-83.62%)
Mutual labels:  node-js
whynote
Command Line Interface to Creating Notes/Tasks
Stars: ✭ 15 (-87.07%)
Mutual labels:  node-js
System-bot
Moderative and user-friendly discord bot using discord.js
Stars: ✭ 39 (-66.38%)
Mutual labels:  node-js





Vulnerabilities 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

  • 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 new URLSearchParams.

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].