index.js 976 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. exports.json = require('./lib/types/json')
  24. /**
  25. * Raw parser.
  26. * @public
  27. */
  28. exports.raw = require('./lib/types/raw')
  29. /**
  30. * Text parser.
  31. * @public
  32. */
  33. exports.text = require('./lib/types/text')
  34. /**
  35. * URL-encoded parser.
  36. * @public
  37. */
  38. exports.urlencoded = require('./lib/types/urlencoded')
  39. /**
  40. * Create a middleware to parse json and urlencoded bodies.
  41. *
  42. * @deprecated
  43. * @public
  44. */
  45. function bodyParser () {
  46. throw new Error('The bodyParser() generic has been split into individual middleware to use instead.')
  47. }