index.js 1.3 KB

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