MCPcopy Index your code
hub / github.com/expressjs/body-parser / createServer

Function createServer

test/json.js:742–760  ·  view source on GitHub ↗
(opts)

Source from the content-addressed store, hash-verified

740})
741
742function createServer (opts) {
743 const _bodyParser = typeof opts !== 'function'
744 ? bodyParser.json(opts)
745 : opts
746
747 return http.createServer(function (req, res) {
748 _bodyParser(req, res, function (err) {
749 if (err) {
750 res.statusCode = err.status || 500
751 res.end(req.headers['x-error-property']
752 ? err[req.headers['x-error-property']]
753 : ('[' + err.type + '] ' + err.message))
754 } else {
755 res.statusCode = 200
756 res.end(JSON.stringify(req.body) || typeof req.body)
757 }
758 })
759 })
760}
761
762function parseError (str) {
763 try {

Callers 1

json.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…