Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

body

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

body

Body parsing

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
603K
decreased by-5.58%
Maintainers
1
Weekly downloads
 
Created
Source

body build status

Body parsing

Example

var body = require("body")
    , jsonBody = body.json
    , formBody = body.form
    , anyBody = body.any
    , http = require("http")
    , sendJson = require("send-data").json

http.createServer(function handleRequest(req, res) {
    if (req.url === "/body") {
        body(req, res, function (err, body) {
            sendJson(req, res, body)
        })
    } else if (req.url === "/form") {
        formBody(req, res, function (err, body) {
            sendJson(req, res, body)
        })
    } else if (req.url === "/json") {
        jsonBody(req, res, function (err, body) {
            sendJson(req, res, body)
        })
    } else if (req.url === "/any") {
        anyBody(req, res, function (err, body) {
            sendJson(req, res, body)
        })
    }
})

body simply parses the request body and returns it in the callback. jsonBody and formBody call JSON.parse and querystring.parse respectively on the body.

anyBody will detect the content-type of the request and use the appropiate body method.

Installation

npm install body

Tests

npm test

Contributors

  • Raynos

MIT Licenced

FAQs

Package last updated on 23 Sep 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc