(opts)
| 740 | }) |
| 741 | |
| 742 | function 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 | |
| 762 | function parseError (str) { |
| 763 | try { |
no outgoing calls
no test coverage detected
searching dependent graphs…