Comparing version 2.1.0 to 3.0.0
18
index.js
@@ -5,2 +5,3 @@ var qs = require('qs') | ||
var createRouter = require('match-routes') | ||
var isType = require('type-is') | ||
var bole = require('bole') | ||
@@ -45,8 +46,17 @@ | ||
if (req.method === 'POST' || req.method === 'PUT' || req.method === 'PATCH') { | ||
parse(req, res, function (err, body) { | ||
if (options.log) log.error('Bad Request, invalid JSON', err) | ||
if (err) return sendError(res, 400, 'Bad Request, invalid JSON') | ||
console.log('isType', isType(req, ['json'])) | ||
if (isType(req, ['json'])) return parse(req, res, handleParse) | ||
callback(req, res, context) | ||
function handleParse (err, body) { | ||
console.log('handleParse') | ||
if (err) { | ||
if (options.log) log.error('Bad Request, invalid JSON', err) | ||
return sendError(res, 400, 'Bad Request, invalid JSON') | ||
} | ||
context.body = body | ||
callback(req, res, context) | ||
}) | ||
} | ||
} else { | ||
@@ -53,0 +63,0 @@ callback(req, res, context) |
{ | ||
"name": "appa", | ||
"version": "2.1.0", | ||
"version": "3.0.0", | ||
"description": "Quickly build micro services.", | ||
@@ -21,2 +21,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"accepts": "^1.3.2", | ||
"body": "^5.1.0", | ||
@@ -23,0 +24,0 @@ "bole": "^2.0.0", |
43809
151
6
+ Addedaccepts@^1.3.2
+ Addedaccepts@1.3.8(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addednegotiator@0.6.3(transitive)