From 7edb90634ce941ac3a65743c32954fd00e85ddd2 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Fri, 3 Nov 2023 11:34:02 +0100 Subject: [PATCH] use reply.response instead of reply --- lib/server/handlers/sthGetDataHandlerV2.js | 12 +++++++----- lib/server/handlers/sthNotificationHandler.js | 6 +++--- lib/server/handlers/sthRemoveDataHandler.js | 8 ++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/server/handlers/sthGetDataHandlerV2.js b/lib/server/handlers/sthGetDataHandlerV2.js index 0a5dbcaa..163e316c 100644 --- a/lib/server/handlers/sthGetDataHandlerV2.js +++ b/lib/server/handlers/sthGetDataHandlerV2.js @@ -42,12 +42,14 @@ function getDataHandler(request, reply) { */ function replyHandler(payload) { if (payload.isBoom) { - return reply({ - error: payload.output.payload.error.replace(/ /, ''), - description: payload.output.payload.message - }).code(payload.output.payload.statusCode); + return reply + .response({ + error: payload.output.payload.error.replace(/ /, ''), + description: payload.output.payload.message + }) + .code(payload.output.payload.statusCode); } - return reply(payload); + return reply.response(payload); } request.params.entityType = request.query.type; diff --git a/lib/server/handlers/sthNotificationHandler.js b/lib/server/handlers/sthNotificationHandler.js index 1e6dac3d..48d976ee 100644 --- a/lib/server/handlers/sthNotificationHandler.js +++ b/lib/server/handlers/sthNotificationHandler.js @@ -163,7 +163,7 @@ function storeRawData(data, reply, callback) { // There was an error when getting the collection sthLogger.error(request.sth.context, 'Error when getting the raw data collection for storing:' + err); if (++counterObj.counter === totalTasks) { - response = reply(err); + response = reply.response(err); sthServerUtils.addFiwareCorrelator(request, response); } process.nextTick(callback.bind(null, err)); @@ -334,13 +334,13 @@ function processAttribute(data, reply) { err = null; } if (++data.counterObj.counter === data.totalTasks) { - reply(err); + reply.response(err); } } else if (isAggregatableValue) { // Store the aggregated data into the database storeAggregatedData(data, reply); } else if (++data.counterObj.counter === data.totalTasks) { - reply(); + reply.response(); } }); } else { diff --git a/lib/server/handlers/sthRemoveDataHandler.js b/lib/server/handlers/sthRemoveDataHandler.js index f1256d30..31c403e3 100644 --- a/lib/server/handlers/sthRemoveDataHandler.js +++ b/lib/server/handlers/sthRemoveDataHandler.js @@ -74,7 +74,7 @@ function removeDataHandler(request, reply) { sthLogger.debug(request.sth.context, 'Responding with 500- Internal error'); const error = boom.internal(message); error.output.payload.message = message; - reply(error); + reply.response(error); } else if ( err.name === 'MongoError' && err.message.includes('does not exist. Currently in strict mode') @@ -85,19 +85,19 @@ function removeDataHandler(request, reply) { 'No data associated to the provided ' + getRequestDescription(request) + ' available' ); // Reply with no error - response = reply(); + response = reply.response(); response.code(204); } else { sthLogger.warn(request.sth.context, 'Error when removing the data associated to an entity: ' + err); // Reply with error - response = reply(err); + response = reply.response(err); } } else { sthLogger.debug( request.sth.context, 'Data associated to the provided ' + getRequestDescription(request) + ' successfully removed' ); - response = reply(); + response = reply.response(); response.code(204); } sthServerUtils.addFiwareCorrelator(request, response);