Skip to content
Permalink
Browse files

deprecate bodyParser() middleware

This deprecates the generic bodyParser() middleware export that
parses both json and urlencoded. The "all" middleware is very
confusing, because it makes it sound like it parses all bodyes,
though it does not do multipart, which is a common body type. Also,
the arguments for the two different middleware are starting to
overlap and it's hard to configure then when done this way.
  • Loading branch information
dougwilson committed Jun 19, 2014
1 parent 6a0ee60 commit b7420f8dc5c8b17a277c9e50d72bbaf3086a3900
Showing with 7 additions and 6 deletions.
  1. +1 −0 HISTORY.md
  2. +0 −5 README.md
  3. +3 −1 index.js
  4. +1 −0 package.json
  5. +2 −0 test/body-parser.js
@@ -3,6 +3,7 @@ unreleased

* check accepted charset in content-type (accepts utf-8)
* check accepted encoding in content-encoding (accepts identity)
* deprecate `bodyParser()` middleware; use `.json()` and `.urlencoded()` as needed
* support gzip and deflate bodies
* deps: raw-body@1.2.1
- Support all encodings from `iconv-lite`
@@ -47,11 +47,6 @@ app.use(function (req, res, next) {
})
```

### bodyParser(options)

Returns middleware that parses both `json` and `urlencoded`.
The `options` are passed to both middleware, except `type`.

### bodyParser.json(options)

Returns middleware that only parses `json`. This parser accepts any Unicode encoding of the body and supports automatic inflation of `gzip` and `deflate` encodings.
@@ -1,5 +1,6 @@

var bytes = require('bytes');
var deprecate = require('depd')('body-parser')
var getBody = require('raw-body');
var typer = require('media-typer');
var typeis = require('type-is');
@@ -9,7 +10,8 @@ var zlib = require('zlib');

var firstcharRegExp = /^\s*(.)/

exports = module.exports = bodyParser;
exports = module.exports = deprecate.function(bodyParser,
'bodyParser: use individual json/urlencoded middlewares')
exports.json = json;
exports.urlencoded = urlencoded;

@@ -10,6 +10,7 @@
"repository": "expressjs/body-parser",
"dependencies": {
"bytes": "1.0.0",
"depd": "0.3.0",
"media-typer": "0.2.0",
"qs": "0.6.6",
"raw-body": "1.2.1",
@@ -1,4 +1,6 @@

process.env.NO_DEPRECATION = 'body-parser'

var assert = require('assert');
var http = require('http');
var request = require('supertest');

0 comments on commit b7420f8

Please sign in to comment.
You can’t perform that action at this time.