From a2950eebc4816e552b97e0e03e3603efc7f0f916 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Wed, 2 Mar 2016 16:21:35 -0500 Subject: [PATCH] Cleanup renamePlacenames --- middleware/renamePlacenames.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/middleware/renamePlacenames.js b/middleware/renamePlacenames.js index 4d1f5248..8f171e24 100644 --- a/middleware/renamePlacenames.js +++ b/middleware/renamePlacenames.js @@ -40,24 +40,24 @@ var PARENT_PROPS = [ function setup() { - return renamePlacenames; } function renamePlacenames(req, res, next) { - // do nothing if no result data set if (!res || !res.data) { return next(); } - res.data = res.data.map(renameStuff); - + res.data = res.data.map(renameOneRecord); + next(); } -function renameStuff(place) { - +/* + * Rename the fields in one record + */ +function renameOneRecord(place) { if (place.address) { Object.keys(ADDRESS_PROPS).forEach(function (prop) { place[ADDRESS_PROPS[prop]] = place.address[prop];