Ein Projekt das es ermöglicht Beerpong über das Internet von zwei unabhängigen positionen aus zu spielen. Entstehung im Rahmen einer Praktikumsaufgabe im Fach Interaktion.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

raw.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*!
  2. * body-parser
  3. * Copyright(c) 2014 Douglas Christopher Wilson
  4. * MIT Licensed
  5. */
  6. /**
  7. * Module dependencies.
  8. */
  9. var bytes = require('bytes')
  10. var read = require('../read')
  11. var typeis = require('type-is')
  12. /**
  13. * Module exports.
  14. */
  15. module.exports = raw
  16. /**
  17. * Create a middleware to parse raw bodies.
  18. *
  19. * @param {object} [options]
  20. * @return {function}
  21. * @api public
  22. */
  23. function raw(options) {
  24. options = options || {};
  25. var inflate = options.inflate !== false
  26. var limit = typeof options.limit !== 'number'
  27. ? bytes(options.limit || '100kb')
  28. : options.limit
  29. var type = options.type || 'application/octet-stream'
  30. var verify = options.verify || false
  31. if (verify !== false && typeof verify !== 'function') {
  32. throw new TypeError('option verify must be function')
  33. }
  34. function parse(buf) {
  35. return buf
  36. }
  37. return function rawParser(req, res, next) {
  38. if (req._body) return next()
  39. req.body = req.body || {}
  40. if (!typeis(req, type)) return next()
  41. // read
  42. read(req, res, next, parse, {
  43. encoding: null,
  44. inflate: inflate,
  45. limit: limit,
  46. verify: verify
  47. })
  48. }
  49. }