index.js
 1  /*!
 2   * body-parser
 3   * Copyright(c) 2014-2015 Douglas Christopher Wilson
 4   * MIT Licensed
 5   */
 6  
 7  'use strict'
 8  
 9  /**
10   * @typedef Parsers
11   * @type {function}
12   * @property {function} json
13   * @property {function} raw
14   * @property {function} text
15   * @property {function} urlencoded
16   */
17  
18  /**
19   * Module exports.
20   * @type {Parsers}
21   */
22  
23  exports = module.exports = bodyParser
24  
25  /**
26   * JSON parser.
27   * @public
28   */
29  
30  Object.defineProperty(exports, 'json', {
31    configurable: true,
32    enumerable: true,
33    get: () => require('./lib/types/json')
34  })
35  
36  /**
37   * Raw parser.
38   * @public
39   */
40  
41  Object.defineProperty(exports, 'raw', {
42    configurable: true,
43    enumerable: true,
44    get: () => require('./lib/types/raw')
45  })
46  
47  /**
48   * Text parser.
49   * @public
50   */
51  
52  Object.defineProperty(exports, 'text', {
53    configurable: true,
54    enumerable: true,
55    get: () => require('./lib/types/text')
56  })
57  
58  /**
59   * URL-encoded parser.
60   * @public
61   */
62  
63  Object.defineProperty(exports, 'urlencoded', {
64    configurable: true,
65    enumerable: true,
66    get: () => require('./lib/types/urlencoded')
67  })
68  
69  /**
70   * Create a middleware to parse json and urlencoded bodies.
71   *
72   * @param {object} [options]
73   * @return {function}
74   * @deprecated
75   * @public
76   */
77  
78  function bodyParser () {
79    throw new Error('The bodyParser() generic has been split into individual middleware to use instead.')
80  }