Comparing version
14
index.js
@@ -89,5 +89,5 @@ var assert = require('assert') | ||
assert.equal(typeof pathname, 'string', 'appa: pathname is required and must be a string') | ||
assert.equal(typeof options, 'object', 'appa: options must be an object') | ||
assert.equal(typeof callback, 'function', 'appa: callback function is required') | ||
assert(typeof pathname === 'string', 'appa: pathname is required and must be a string') | ||
assert(typeof options === 'object', 'appa: options must be an object') | ||
assert(typeof callback === 'function', 'appa: callback function is required') | ||
@@ -113,3 +113,9 @@ options.parseJSON = options.parseJSON === false ? options.parseJSON : true | ||
if (isType(req, ['json']) && options.parseJSON) { | ||
ctx.body = parseJSON(res, result) | ||
result = parseJSON(res, result) | ||
if (result.err) { | ||
return error(res, 400, 'Malformed JSON') | ||
} else { | ||
ctx.body = result.value | ||
} | ||
} else { | ||
@@ -116,0 +122,0 @@ ctx.body = result |
{ | ||
"name": "appa-api", | ||
"version": "7.0.1", | ||
"version": "8.0.0", | ||
"description": "Quickly create simple HTTP services.", | ||
@@ -25,23 +25,23 @@ "main": "index.js", | ||
"dependencies": { | ||
"JSONStream": "^1.3.1", | ||
"fast-json-parse": "^1.0.2", | ||
"pino": "^4.5.2", | ||
"pino-http": "^2.6.1", | ||
"pump": "^1.0.2", | ||
"qs": "^6.4.0", | ||
"raw-body": "^2.2.0", | ||
"JSONStream": "^1.3.4", | ||
"fast-json-parse": "^1.0.3", | ||
"pino": "^5.5.0", | ||
"pino-http": "^4.0.0", | ||
"pump": "^3.0.0", | ||
"qs": "^6.5.2", | ||
"raw-body": "^2.3.3", | ||
"send-response": "^1.0.0", | ||
"type-is": "^1.6.15", | ||
"wayfarer": "^6.6.0" | ||
"type-is": "^1.6.16", | ||
"wayfarer": "^6.6.4" | ||
}, | ||
"devDependencies": { | ||
"dependency-check": "^2.8.0", | ||
"documentation": "^4.0.0-rc.1", | ||
"dependency-check": "^3.2.0", | ||
"documentation": "^8.1.2", | ||
"from2-string": "^1.1.0", | ||
"into-stream": "^3.1.0", | ||
"request": "^2.81.0", | ||
"standard": "^10.0.2", | ||
"tap-spec": "^4.1.1", | ||
"tape": "^4.6.3" | ||
"request": "^2.88.0", | ||
"standard": "^12.0.1", | ||
"tap-spec": "^5.0.0", | ||
"tape": "^4.9.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
60964
0.17%341
1.49%22
-4.35%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated
Updated
Updated
Updated
Updated
Updated