MCPcopy Create free account
hub / github.com/expressjs/body-parser / createServer

Function createServer

test/raw.js:503–524  ·  view source on GitHub ↗
(opts)

Source from the content-addressed store, hash-verified

501})
502
503function createServer (opts) {
504 const _bodyParser = typeof opts !== 'function'
505 ? bodyParser.raw(opts)
506 : opts
507
508 return http.createServer(function (req, res) {
509 _bodyParser(req, res, function (err) {
510 if (err) {
511 res.statusCode = err.status || 500
512 res.end('[' + err.type + '] ' + err.message)
513 return
514 }
515
516 if (Buffer.isBuffer(req.body)) {
517 res.end('buf:' + req.body.toString('hex'))
518 return
519 }
520
521 res.end(JSON.stringify(req.body) || typeof req.body)
522 })
523 })
524}

Callers 1

raw.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected