* Create a middleware to parse json and urlencoded bodies. * * @param {object} [options] * @return {function} * @deprecated * @public
(options)
| 91 | */ |
| 92 | |
| 93 | function bodyParser (options) { |
| 94 | // use default type for parsers |
| 95 | var opts = Object.create(options || null, { |
| 96 | type: { |
| 97 | configurable: true, |
| 98 | enumerable: true, |
| 99 | value: undefined, |
| 100 | writable: true |
| 101 | } |
| 102 | }) |
| 103 | |
| 104 | var _urlencoded = exports.urlencoded(opts) |
| 105 | var _json = exports.json(opts) |
| 106 | |
| 107 | return function bodyParser (req, res, next) { |
| 108 | _json(req, res, function (err) { |
| 109 | if (err) return next(err) |
| 110 | _urlencoded(req, res, next) |
| 111 | }) |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Create a getter for loading a parser. |
no outgoing calls
no test coverage detected