New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@frameworkless/bodyparser

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@frameworkless/bodyparser

The simplest and easiest to use body parser for formdata.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@frameworkless/bodyparser

The easiest to use body parser for Node.js applications. Works with any content type, and comes standard with a few useful ones.

This module comes from the output of the Frameworkless.js online course.

Installing

npm i --save @frameworkless/bodyparser

Quick Start

Here's the quick, simple usage with the Node's built in HTTP server:

const { createServer } = require('http')
const { parseBody } = require('@frameworkless/bodyparser')

const requestHandler = async (request, response) => {
  const payload = await parseBody(request)
  return response.end(payload)
}

const server = createServer(requestHandler)

server.listen(1234)

File Uploads

File uploads will work out of the box, via multipart form parsing. The only thing you need to do is whitelist the types of files you want to upload. This can be done via one of two ways:

  1. Environment variable (recommended): set ALLOWED_ATTACHMENT_MIMES to a comma-separated list of files you want to whitelist, for example: image/png,text/html
  2. Pass it in to the options argument: by passing in a fileTypes option, you will be able to overwrite this per-request if you pass in an array of mime types. So your code might look like:
const payload = await parseBody(request, { fileTypes: [ 'image/png', 'text/html' ] })

Tests

npm run test

Contributing

I would love your help! Please make an issue or better yet create a pull request if you find a bug or missing feature!

Keywords

FAQs

Package last updated on 03 Nov 2020

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