From c1f2b96bfcf85e71b4b28585a3d51a7aa8f356fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 17 Nov 2017 18:32:19 +0100 Subject: [PATCH] Remove step from catalog middleware --- lib/cartodb/controllers/analyses.js | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/lib/cartodb/controllers/analyses.js b/lib/cartodb/controllers/analyses.js index 7a6d75f8..19c1f91b 100644 --- a/lib/cartodb/controllers/analyses.js +++ b/lib/cartodb/controllers/analyses.js @@ -28,26 +28,21 @@ AnalysesController.prototype.register = function(app) { AnalysesController.prototype.catalog = function () { return function catalogMiddleware(req, res, next) { const { user } = res.locals; + const pg = new PSQL(dbParamsFromReqParams(res.locals)); - step( - function catalogQuery() { - var pg = new PSQL(dbParamsFromReqParams(res.locals)); - getMetadata(user, pg, this); - }, - function prepareResponse(err, catalogWithTables) { - if (err) { - if (err.message.match(/permission\sdenied/)) { - err = new Error('Unauthorized'); - err.http_status = 401; - } - - return next(err); + getMetadata(user, pg, (err, catalogWithTables) => { + if (err) { + if (err.message.match(/permission\sdenied/)) { + err = new Error('Unauthorized'); + err.http_status = 401; } - res.locals.catalogWithTables = catalogWithTables; - next(); + return next(err); } - ); + + res.locals.catalogWithTables = catalogWithTables; + next(); + }); }; };