Skip to content

Commit

Permalink
use reply.response instead of reply
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroVega committed Nov 3, 2023
1 parent 87e9d70 commit 7edb906
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
12 changes: 7 additions & 5 deletions lib/server/handlers/sthGetDataHandlerV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions lib/server/handlers/sthNotificationHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions lib/server/handlers/sthRemoveDataHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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);
Expand Down

0 comments on commit 7edb906

Please sign in to comment.