index.js 1.3 KB

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