Comparing version 3.0.0 to 3.0.1
30
index.js
@@ -43,22 +43,20 @@ var qs = require('qs') | ||
context.query = qs.parse(context.query) | ||
function handleParse (err, body) { | ||
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) | ||
} | ||
if (options.log) log.info('request context', context) | ||
if (req.method === 'POST' || req.method === 'PUT' || req.method === 'PATCH') { | ||
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') | ||
} | ||
return callback(req, res, context) | ||
} | ||
context.body = body | ||
callback(req, res, context) | ||
} | ||
} else { | ||
callback(req, res, context) | ||
} | ||
callback(req, res, context) | ||
}) | ||
@@ -65,0 +63,0 @@ } |
{ | ||
"name": "appa", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Quickly build micro services.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
43678
148