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(); + }); }; };