From 17ca3aaf70e4322807b4a0ed4087dc7d1058037b Mon Sep 17 00:00:00 2001 From: Kristoffer Walker Date: Sun, 17 Jul 2016 06:04:15 -0400 Subject: [PATCH 1/2] Correctly include port number in JSON API links modified: lib/middleware/response-json-api.js --- lib/middleware/response-json-api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/middleware/response-json-api.js b/lib/middleware/response-json-api.js index fa3855c..219c666 100644 --- a/lib/middleware/response-json-api.js +++ b/lib/middleware/response-json-api.js @@ -109,7 +109,7 @@ module.exports = function (options) { defaultPort = true; } - if (defaultPort) { + if (!defaultPort) { baseUrl = `${baseUrl}:${port}`; } if (BASE_PREFIX) { From 86119d2e63a34ee65152a85bc7d668ddc97ee750 Mon Sep 17 00:00:00 2001 From: Kristoffer Walker Date: Sun, 17 Jul 2016 09:37:35 -0400 Subject: [PATCH 2/2] Fixes JSON API error output modified: lib/middleware/error-handler.js --- lib/middleware/error-handler.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/middleware/error-handler.js b/lib/middleware/error-handler.js index 6894cb0..4c71fce 100644 --- a/lib/middleware/error-handler.js +++ b/lib/middleware/error-handler.js @@ -20,9 +20,9 @@ module.exports = function (options) { function formatError(error) { const output = error.output || {}; return { - status: output.statusCode ? output.statusCode.toString() : null, - title: error.name, - detail: error.message + status: output.statusCode ? output.statusCode.toString() : '500', + title: output.payload ? output.payload.error : error.name, + detail: output.payload ? output.payload.message : (error.message || error.toString()) }; }