@rill/body

1.3.0 • Public • Published

Rill
@rill/body
API stability Standard NPM version Downloads Gitter Chat

Isomorphic request body parser for Rill. Uses formidable to parse form data.

Installation

npm install @rill/body

Example

const app = require("rill")()
const bodyParser = require("@rill/body")

app.use(bodyParser())
app.use(function ({ req, res }, next) {
	req.body // Object containing parsed form fields.
	req.files // Object of form fields with files.
})

API Options / Defaults.

{
	// Form encoding.
	encoding: "utf-8",
	// Max size (in bytes) for forms.
	limit: "2mb",
	// Max number of fields (0 for unlimited).
	limitFields: 1000,
	// Ignore form data parsing on GET, HEAD and DELETE requests.
	strict: true,
	// When flat is false fields such as a[b][c] won't be expanded.
	flat: false,
	// A function that can modify all fields parsed.
	transformField: (field, value)=> ...,
	// A function that can modify all files parsed.
	transformFile: (field, file)=> ...,
}

Contributions

  • Use npm test to run tests.

Please feel free to create a PR!

Package Sidebar

Install

npm i @rill/body

Weekly Downloads

15

Version

1.3.0

License

MIT

Last publish

Collaborators

  • dylanpiercey